home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_01_01 / 1n01082a < prev    next >
Text File  |  1990-05-17  |  1KB  |  42 lines

  1. /*
  2.     Header:     PtrDebug
  3.     Version:    1.00
  4.  
  5.     Language:   ANSI C
  6.     Environ:    Any
  7.  
  8.     Purpose:    Provides debug replacements for the standard
  9.                 dynamic memory allocation functions.
  10.  
  11.     Written by: Scott Robert Ladd
  12. */
  13.  
  14. #if !defined(_PTRDEBUG_H)
  15. #define _PTRDEBUG_H
  16.  
  17. #include "stddef.h"
  18.  
  19. /* change calls to traditional functions to call debug functions */
  20.  
  21. #if !defined(NO_PTRDEBUG_DEF)
  22.     #define malloc(a)    dbg_malloc(a,__FILE__,__LINE__)
  23.     #define calloc(a,b)  dbg_calloc(a,b,__FILE__,__LINE__)
  24.     #define realloc(a,b) dbg_realloc(a,b,__FILE__,__LINE__)
  25.     #define free(a)      dbg_free(&a,__FILE__,__LINE__)
  26.     #define strdup(a)    dbg_strdup(a,__FILE__,__LINE__)
  27. #endif
  28.  
  29. /* prototypes for debug functions */
  30.  
  31. void * dbg_malloc(size_t len, char * file, int line);
  32.  
  33. void * dbg_calloc(size_t num, size_t len, char * file, int line);
  34.  
  35. void * dbg_realloc(void * ptr, size_t len, char * file, int line);
  36.  
  37. void dbg_free(void ** ptr, char * file, int line);
  38.  
  39. char * dbg_strdup(char * str, char * file, int line);
  40.  
  41. #endif
  42.