home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progc / dmldmo.arj / DMALLOC.H < prev    next >
C/C++ Source or Header  |  1992-04-12  |  5KB  |  152 lines

  1. /***************************************************************************/
  2. /*                                                                         */
  3. /* DMALLOC.H v.0.9 for MSC 5.1 and 6.+                                     */
  4. /*                                                                         */
  5. /* (C) 1991-1992 E.Vogelsinger                                    03/30/92 */
  6. /***************************************************************************/
  7.  
  8. #if !defined(_DMALLOC_INCLUDED)
  9. #define _DMALLOC_INCLUDED
  10.  
  11. /* ==== a) Definitions =================================================== */
  12.  
  13. // Valid values for DML_Setup and DML_Select
  14. #define SET_OFF        0
  15. #define SET_ON         1
  16.  
  17. #define SET_SAVED      1
  18. #define SET_CORRUPTED  2
  19. #define SET_BOTH       3
  20.  
  21. #define SET_UNCHANGED -1
  22. #define PSZ_UNCHANGED  ((void *)-1)
  23.  
  24. // Valid values for DML_Breakpoint
  25. #define BPT_SOFTICE    1
  26. #define BPT_CODEVIEW   2
  27. #define BPT_INT3       3
  28.  
  29. // Values for Watchpoint
  30. #define FAR_NULLCHECK  ((void *)0)
  31. #define DATA_NULLCHECK ((void *)1)
  32.  
  33.  
  34. /* ==== b) Macros ======================================================== */
  35.  
  36. // check if we are really compiling large model
  37. #if defined _DMALLOC
  38. # if !defined M_I86LM && !defined M_I86CM
  39. #  undef _DMALLOC
  40. #  pragma message ("DMalloc v.1.0 needs the LARGE memory model!")
  41. #  error *** Abort ***
  42. # endif
  43. #endif
  44.  
  45. #if !defined _DMALLOC
  46.  
  47. // if DMalloc is switched off, define anything so the compiler
  48. // would not protest
  49.  
  50. #define DML_Trigger()
  51. #define DML_Setup(f1,f2,f3)
  52. #define DML_Select(f1,f2,f3,f4,f5,p,l)
  53. #define DML_SaveState(p)
  54. #define DML_RestoreState(p)
  55. #define DML_Watchpoint(p,f)   (1)   // returns nonzero if ptr is valid
  56. #define DML_Savepoint(p,f)    (1)   // here we must assume it is!
  57. #define DML_Breakpoint(f)
  58. #define DML_Disable()
  59. #define DML_Enable()
  60. #define DML_Check()
  61. #define DML_SAVEAREA(name)
  62.  
  63. #else
  64.  
  65.  
  66. // let the programmer know that DMalloc is on
  67. #pragma message ("DMalloc heap check enabled")
  68.  
  69.  
  70. // redefine the malloc function calls to our entry points
  71.  
  72. #define malloc(size)       DM_malloc$(size,__FILE__,__LINE__)
  73. #define free(ptr)          DM_free$(ptr,__FILE__,__LINE__)
  74. #define calloc(cnt,size)   DM_calloc$(cnt,size,__FILE__,__LINE__)
  75. #define realloc(ptr,size)  DM_realloc$(ptr,size,__FILE__,__LINE__)
  76.  
  77. #define _fmalloc(size)     DM_malloc$(size,__FILE__,__LINE__)
  78. #define _ffree(ptr)        DM_free$(ptr,__FILE__,__LINE__)
  79. #define _nmalloc(size)     DM_nmalloc$(size,__FILE__,__LINE__)
  80. #define _nfree(ptr)        DM_nfree$(ptr,__FILE__,__LINE__)
  81.  
  82. // using DML_Trigger, we want to have information about the
  83. // source as well
  84. #define DML_Trigger()      DM_Trigger$(__FILE__, __LINE__)
  85.  
  86.  
  87. // define the buffer variable needed to save the DMalloc state
  88. #define DML_SAVESIZE       (128)
  89. #define DML_SAVEAREA(name) char name[DML_SAVESIZE]
  90.  
  91.  
  92. /* ==== c) Typedefs ====================================================== */
  93.  
  94. #if !defined _SIZE_T_DEFINED
  95. typedef unsigned int size_t;
  96. #define _SIZE_T_DEFINED
  97. #endif
  98.  
  99.  
  100. /* ==== d) Prototypes ==================================================== */
  101.  
  102. void *          DM_malloc$      (size_t   size,
  103.                                  char *   pszFile,
  104.                                  unsigned usLine);
  105. void            DM_free$        (void *   pUnit,
  106.                                  char *   pszFile,
  107.                                  unsigned usLine);
  108. void *          DM_calloc$      (size_t   size,
  109.                                  size_t   count,
  110.                                  char *   pszFile,
  111.                                  unsigned usLine);
  112. void *          DM_realloc$     (void *   pUnit,
  113.                                  size_t   size,
  114.                                  char *   pszFile,
  115.                                  unsigned usLine);
  116. void *          DM_nmalloc$     (size_t   size,
  117.                                  char *   pszFile,
  118.                                  unsigned usLine);
  119. void            DM_nfree$       (void *   pUnit,
  120.                                  char *   pszFile,
  121.                                  unsigned usLine);
  122. void     pascal DM_Trigger$     (char *   pszFile,
  123.                                  unsigned usLine);
  124.  
  125. void     pascal DML_Setup       (unsigned fAlert,
  126.                                  unsigned fSaved,
  127.                                  unsigned usPopCycles,
  128.                                  unsigned usCheckCycles,
  129.                                  char *   pszOwner,
  130.                                  unsigned usLine);
  131. void     pascal DML_Select      (unsigned fMalloc,
  132.                                  unsigned fMarked,
  133.                                  unsigned fNull,
  134.                                  unsigned fData,
  135.                                  unsigned fSystem,
  136.                                  char     *pszOwner,
  137.                                  unsigned usLine);
  138. void     pascal DML_SaveState   (void *   pSave);
  139. void     pascal DML_RestoreState(void *   pSave);
  140. unsigned pascal DML_Watchpoint  (void far *p,
  141.                                  unsigned fOnOff);
  142. unsigned pascal DML_Savepoint   (void far *p,
  143.                                  unsigned fOnOff);
  144. void     pascal DML_Breakpoint  (unsigned fType);
  145. void     pascal DML_Disable     (void);
  146. void     pascal DML_Enable      (void);
  147. void     pascal DML_Check       (void);
  148.  
  149. #endif
  150. #endif
  151.  
  152.