home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dmake40.zip / dbug / malloc / m_perror.c < prev    next >
C/C++ Source or Header  |  1994-10-23  |  2KB  |  100 lines

  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.1 1994/10/06 17:43:12 dvadura 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
  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. /*
  75.  * $Log: m_perror.c,v $
  76.  * Revision 1.1  1994/10/06  17:43:12  dvadura
  77.  * dmake Release Version 4.0, Initial revision
  78.  *
  79.  * Revision 1.1  1994/10/06  03:45:21  dvadura
  80.  * dmake Release Version 4.0, Initial revision
  81.  *
  82.  * Revision 1.1  1992/01/24  03:29:04  dvadura
  83.  * dmake Version 3.8, Initial revision
  84.  *
  85.  * Revision 1.5  90/08/29  21:25:08  cpcahil
  86.  * added additional error message that was missing (and 
  87.  * caused a core dump)
  88.  * 
  89.  * Revision 1.4  90/05/11  00:13:08  cpcahil
  90.  * added copyright statment
  91.  * 
  92.  * Revision 1.3  90/02/24  21:50:21  cpcahil
  93.  * lots of lint fixes
  94.  * 
  95.  * Revision 1.2  90/02/24  17:39:55  cpcahil
  96.  * 1. added function header
  97.  * 2. added rcs id and log strings.
  98.  * 
  99.  */
  100.