home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / m_perror.c < prev    next >
C/C++ Source or Header  |  1993-01-04  |  4KB  |  161 lines

  1. /*
  2.  * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  3.  *
  4.  * This software may be distributed freely as long as the following conditions
  5.  * are met:
  6.  *         * the distribution, or any derivative thereof, may not be
  7.  *          included as part of a commercial product
  8.  *        * full source code is provided including this copyright
  9.  *        * there is no charge for the software itself (there may be
  10.  *          a minimal charge for the copying or distribution effort)
  11.  *        * this copyright notice is not modified or removed from any
  12.  *          source file
  13.  */
  14.  
  15. #ifndef lint
  16. static
  17. char rcsid[] = "$Id: m_perror.c,v 1.23 1992/08/22 16:27:13 cpcahil Exp $";
  18. #endif
  19.  
  20. #include "mallocin.h"
  21.  
  22. /*
  23.  * malloc errno error strings...
  24.  */
  25.  
  26. CONST char *malloc_err_strings[] = 
  27. {
  28.     "No errors",
  29.     "Malloc chain is corrupted, pointers out of order",
  30.     "Malloc chain is corrupted, end before end pointer",
  31.     "Pointer is not within malloc area",
  32.     "Malloc region does not have valid magic number in header",
  33.     "Pointers between this segment and adjoining segments are invalid",
  34.     "Data has overrun beyond requested number of bytes",
  35.     "Data in free'd area has been modified",
  36.     "Data area is not in use (can't be freed or realloced, or used)",
  37.     "Unable to get additional memory from the system",
  38.     "Pointer within malloc region, but outside of malloc data bounds",
  39.     "Malloc segment in free list is in-use",
  40.     "Unable to determine doubleword boundary",
  41.     "No current function on stack, probably missing call to malloc_enter ",
  42.     "Current function name doesn't match name on stack",
  43.     "Data has written before beginning of requested bytes",
  44.     "Free of a marked segment",
  45.     "Allocation of zero length segment",
  46.     (CONST char *) 0
  47. };
  48.  
  49. /*
  50.  * Function:    malloc_perror()
  51.  *
  52.  * Purpose:    to print malloc_errno error message
  53.  *
  54.  * Arguments:    str    - string to print with error message
  55.  *
  56.  * Returns:    nothing of any value
  57.  *
  58.  * Narrative:
  59.  */
  60. VOIDTYPE
  61. malloc_perror(str)
  62.     CONST char    * str;
  63. {
  64.     register CONST char     * s;
  65.     register CONST char     * t;
  66.  
  67.     if( str && *str)
  68.     {
  69.         for(s=str; *s; s++)
  70.         {
  71.             /* do nothing */;
  72.         }
  73.  
  74.         VOIDCAST write(2,str,(WRTSIZE)(s-str));
  75.         VOIDCAST write(2,": ",(WRTSIZE)2);
  76.     }
  77.  
  78.     t = malloc_err_strings[malloc_errno];
  79.  
  80.     for(s=t; *s; s++)
  81.     {
  82.         /* do nothing */;
  83.     }
  84.  
  85.     VOIDCAST write(2,t,(WRTSIZE)(s-t));
  86.  
  87.     VOIDCAST write(2,"\n",(WRTSIZE)1);
  88. }
  89.  
  90. /*
  91.  * $Log: m_perror.c,v $
  92.  * Revision 1.23  1992/08/22  16:27:13  cpcahil
  93.  * final changes for pl14
  94.  *
  95.  * Revision 1.22  1992/07/03  00:03:25  cpcahil
  96.  * more fixes for pl13, several suggestons from Rich Salz.
  97.  *
  98.  * Revision 1.21  1992/06/22  23:40:10  cpcahil
  99.  * many fixes for working on small int systems
  100.  *
  101.  * Revision 1.20  1992/05/08  02:30:35  cpcahil
  102.  * minor cleanups from minix/atari port
  103.  *
  104.  * Revision 1.19  1992/05/08  01:44:11  cpcahil
  105.  * more performance enhancements
  106.  *
  107.  * Revision 1.18  1992/05/06  04:53:29  cpcahil
  108.  * performance enhancments
  109.  *
  110.  * Revision 1.17  1992/04/20  22:29:14  cpcahil
  111.  * changes to fix problems introduced by insertion of size_t
  112.  *
  113.  * Revision 1.16  1992/04/15  12:51:06  cpcahil
  114.  * fixes per testing of patch 8
  115.  *
  116.  * Revision 1.15  1992/04/15  11:47:54  cpcahil
  117.  * spelling changes.
  118.  *
  119.  * Revision 1.14  1992/04/14  01:15:25  cpcahil
  120.  * port to RS/6000
  121.  *
  122.  * Revision 1.13  1992/04/13  03:06:33  cpcahil
  123.  * Added Stack support, marking of non-leaks, auto-config, auto-testing
  124.  *
  125.  * Revision 1.12  1992/03/01  12:42:38  cpcahil
  126.  * added support for managing freed areas and fixed doublword bndr problems
  127.  *
  128.  * Revision 1.11  1992/02/19  01:42:29  cpcahil
  129.  * fixed typo in error message
  130.  *
  131.  * Revision 1.10  1992/01/30  12:23:06  cpcahil
  132.  * renamed mallocint.h -> mallocin.h
  133.  *
  134.  * Revision 1.9  1992/01/10  17:28:03  cpcahil
  135.  * Added support for overriding void datatype
  136.  *
  137.  * Revision 1.8  1991/12/04  09:23:38  cpcahil
  138.  * several performance enhancements including addition of free list
  139.  *
  140.  * Revision 1.7  91/11/25  14:41:55  cpcahil
  141.  * Final changes in preparation for patch 4 release
  142.  * 
  143.  * Revision 1.6  91/11/24  00:49:27  cpcahil
  144.  * first cut at patch 4
  145.  * 
  146.  * Revision 1.5  90/08/29  21:25:08  cpcahil
  147.  * added additional error message that was missing (and 
  148.  * caused a core dump)
  149.  * 
  150.  * Revision 1.4  90/05/11  00:13:08  cpcahil
  151.  * added copyright statment
  152.  * 
  153.  * Revision 1.3  90/02/24  21:50:21  cpcahil
  154.  * lots of lint fixes
  155.  * 
  156.  * Revision 1.2  90/02/24  17:39:55  cpcahil
  157.  * 1. added function header
  158.  * 2. added rcs id and log strings.
  159.  * 
  160.  */
  161.