home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_09_10 / 9n10057a < prev    next >
Text File  |  1991-01-23  |  1KB  |  38 lines

  1. /*  memdebug.h  header file for debugging versions of malloc, 
  2.  *  calloc, realloc and free.  To use:  place #define DEBUG 
  3.  *  line before  #include "memdebug.h" in program to debug.
  4.  *  Copyright 1990 by Wahhab Baldwin.  Permission to copy 
  5.  *  freely granted if this notice is included.
  6. */
  7.  
  8. #ifndef _SIZE_T_DEFINED
  9. typedef unsigned int size_t;
  10. #define _SIZE_T_DEFINED
  11. #endif
  12.  
  13. typedef struct memchain {
  14.     unsigned int line;
  15.     unsigned short module_ix;
  16.     size_t bytes;
  17.     struct memchain *next;
  18.     struct memchain *prev;
  19.     unsigned int sentinal;
  20. } MEMCHAIN, *PMEMCHAIN;
  21.  
  22. #if defined(DEBUG)
  23. /* redefine normal library memory calls */
  24. #define malloc(x) d__malloc(x, __FILE__, __LINE__)
  25. #define calloc(x, y) d__calloc(x, y, __FILE__, __LINE__)
  26. #define realloc(x, y) d__realloc(x, y, __FILE__, __LINE__)
  27. #define free(x) d__free(x, __FILE__, __LINE__)
  28.  
  29. /* function prototypes */
  30. void *d__malloc(size_t bytes, char *module, int line);
  31. void *d__calloc(size_t n, size_t bytes, char *module, 
  32.                 int line);
  33. void *d__realloc(void *rptr, size_t bytes, char *module, 
  34.                 int line);
  35. void *d__showmem(void);
  36. #endif
  37. /* end of memdebug.h */
  38.