1 /*
2  * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
3  * You may copy, distribute, and use this software as long as this
4  * copyright statement is not removed.
5  */
6 
7 #ifndef lint
8 static
9 char rcsid[] = "$Id: m_perror.c,v 1.2 2006-07-25 10:08:21 rt Exp $";
10 #endif
11 
12 /*
13  * malloc errno error strings...
14  */
15 
16 char *malloc_err_strings[] =
17 {
18 	"No errors",
19 	"Malloc chain is corrupted, pointers out of order",
20 	"Malloc chain is corrupted, end before end pointer",
21 	"Pointer is not within malloc area",
22 	"Malloc region does not have valid magic number in header",
23 	"Pointers between this segment and ajoining segments are invalid",
24 	"Data has overrun beyond requested number of bytes",
25 	"Data in free'd area has been modified",
26 	"Data are is not in use (can't be freed or realloced)",
27 	"Unable to get additional memory from the system",
28 	"Pointer within malloc region, but outside of malloc data bounds",
29 	(char *) 0
30 };
31 
32 /*
33  * Function:	malloc_perror()
34  *
35  * Purpose:	to print malloc_errno error message
36  *
37  * Arguments:	str	- string to print with error message
38  *
39  * Returns:	nothing of any value
40  *
41  * Narrative:
42  */
43 void
malloc_perror(str)44 malloc_perror(str)
45 	char	* str;
46 {
47 	extern int	  malloc_errno;
48 	register char 	* s;
49 	register char 	* t;
50 
51 	if( str && *str)
52 	{
53 		for(s=str; *s; s++)
54 		{
55 			/* do nothing */;
56 		}
57 
58 		(void) write(2,str,(unsigned)(s-str));
59 		(void) write(2,": ",(unsigned)2);
60 	}
61 
62 	t = malloc_err_strings[malloc_errno];
63 
64 	for(s=t; *s; s++)
65 	{
66 		/* do nothing */;
67 	}
68 
69 	(void) write(2,t,(unsigned)(s-t));
70 
71 	(void) write(2,"\n",(unsigned)1);
72 }
73 
74