summaryrefslogtreecommitdiff
path: root/dmake/dbug/malloc/m_perror.c
diff options
context:
space:
mode:
Diffstat (limited to 'dmake/dbug/malloc/m_perror.c')
-rw-r--r--dmake/dbug/malloc/m_perror.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/dmake/dbug/malloc/m_perror.c b/dmake/dbug/malloc/m_perror.c
new file mode 100644
index 000000000000..b5620182ac4e
--- /dev/null
+++ b/dmake/dbug/malloc/m_perror.c
@@ -0,0 +1,73 @@
+/*
+ * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
+ * You may copy, distribute, and use this software as long as this
+ * copyright statement is not removed.
+ */
+
+#ifndef lint
+static
+char rcsid[] = "$Id: m_perror.c,v 1.2 2006-07-25 10:08:21 rt Exp $";
+#endif
+
+/*
+ * malloc errno error strings...
+ */
+
+char *malloc_err_strings[] =
+{
+ "No errors",
+ "Malloc chain is corrupted, pointers out of order",
+ "Malloc chain is corrupted, end before end pointer",
+ "Pointer is not within malloc area",
+ "Malloc region does not have valid magic number in header",
+ "Pointers between this segment and ajoining segments are invalid",
+ "Data has overrun beyond requested number of bytes",
+ "Data in free'd area has been modified",
+ "Data are is not in use (can't be freed or realloced)",
+ "Unable to get additional memory from the system",
+ "Pointer within malloc region, but outside of malloc data bounds",
+ (char *) 0
+};
+
+/*
+ * Function: malloc_perror()
+ *
+ * Purpose: to print malloc_errno error message
+ *
+ * Arguments: str - string to print with error message
+ *
+ * Returns: nothing of any value
+ *
+ * Narrative:
+ */
+void
+malloc_perror(str)
+ char * str;
+{
+ extern int malloc_errno;
+ register char * s;
+ register char * t;
+
+ if( str && *str)
+ {
+ for(s=str; *s; s++)
+ {
+ /* do nothing */;
+ }
+
+ (void) write(2,str,(unsigned)(s-str));
+ (void) write(2,": ",(unsigned)2);
+ }
+
+ t = malloc_err_strings[malloc_errno];
+
+ for(s=t; *s; s++)
+ {
+ /* do nothing */;
+ }
+
+ (void) write(2,t,(unsigned)(s-t));
+
+ (void) write(2,"\n",(unsigned)1);
+}
+