home *** CD-ROM | disk | FTP | other *** search
/ Resource for Source: C/C++ / Resource for Source - C-C++.iso / misc_src / cslib16b / include / csmalloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-01  |  2.5 KB  |  65 lines

  1. /***********************************************************************
  2.  
  3.                                        CSA Library, Version 1.6.b 
  4.                                          Released: March 2nd 1995 
  5.  
  6.        Preprocessor commands to replace all the memory
  7.        allocation functions with new ones which log
  8.        and check the use of the heap.
  9.  
  10.                                            Copyright(c) 1994,1995 
  11.                                                            Combis 
  12.                                                   The Netherlands 
  13. ***********************************************************************/
  14.  
  15. #ifndef __CSMALLOC_H
  16. #define __CSMALLOC_H
  17.  
  18.  
  19. #include "alloc.h"
  20. #include "malloc.h"
  21. #include "stdlib.h"
  22.  
  23.  
  24. #if defined(CS_DEBUG)
  25.  
  26.   #define  csmalloc(x)         cs_malloc(x,      __FILE__,__LINE__)
  27.   #define  cscalloc(x,y)     cs_calloc(x,y,    __FILE__,__LINE__)
  28.   #define  csrealloc(x,y)    cs_realloc(x,y,   __FILE__,__LINE__)
  29.   #define  csfree(x)         cs_free(x,        __FILE__,__LINE__)
  30.   #define  csfarmalloc(x)    cs_farmalloc(x,   __FILE__,__LINE__)
  31.   #define  csfarcalloc(x,y)  cs_farcalloc(x,y, __FILE__,__LINE__)
  32.   #define  csfarrealloc(x,y) cs_farrealloc(x,y,__FILE__,__LINE__)
  33.   #define  csfarfree(x)      cs_farfree(x,     __FILE__,__LINE__)
  34.  
  35. #else
  36.  
  37.   #define  csmalloc(x)          ::malloc(x)
  38.   #define  cscalloc(x,y)      ::calloc(x,y)
  39.   #define  csrealloc(x,y)     ::realloc(x,y)
  40.   #define  csfree(x)          ::free(x)
  41.   #define  csfarmalloc(x)     ::farmalloc(x)
  42.   #define  csfarcalloc(x,y)   ::farcalloc(x,y)
  43.   #define  csfarrealloc(x,y)  ::farrealloc(x,y)
  44.   #define  csfarfree(x)       ::farfree(x)
  45.  
  46. #endif
  47.  
  48.  
  49. void   alloc_logging(int TrueFalse,CSCHAR *name);
  50. void   alloc_test(CSCHAR *fname,long line);
  51. inline void  alloc_logging(int TrueFalse) { alloc_logging(TrueFalse,"malloc.log"); }
  52.  
  53. void far  * _Cdecl cs_farcalloc(unsigned long __nunits, unsigned long __unitsz,CSCHAR *fname,long line);
  54. void far  * _Cdecl cs_farrealloc(void far * ptr,unsigned long __nunits, unsigned long __unitsz,CSCHAR *fname,long line);
  55. void        _Cdecl cs_farfree(void far *__block,CSCHAR *fname,long line);
  56. void far  * _Cdecl cs_farmalloc(unsigned long __nbytes,CSCHAR *fname,long line);
  57.  
  58. void _FAR * _Cdecl cs_realloc(void _FAR *ptr, size_t __size,CSCHAR *fname,long line);
  59. void _FAR * _Cdecl cs_calloc(size_t __nitems, size_t __size,CSCHAR *fname,long line);
  60. void        _Cdecl cs_free(void _FAR *__block,CSCHAR *fname,long line);
  61. void _FAR * _Cdecl cs_malloc(size_t __size,CSCHAR *fname,long line);
  62.  
  63.  
  64. #endif
  65.