home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / JMALLOC.H < prev    next >
C/C++ Source or Header  |  1997-07-05  |  6KB  |  146 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*--------------------------------------------------------------*/
  4. /* Debugging extension by Jeff Dunlop                           */
  5. /* Copyright 1992-1993, DB/Soft Publishing Co.                  */
  6. /* License is hereby granted for use of JMalloc as a debugging  */
  7. /* aid in any program.  JMalloc may not be sold or distributed  */
  8. /* as or part of any for-profit debugging program or library    */
  9. /* nor may it be included in any for-profit library that offers */
  10. /* debugging features.  Any redistribution of JMalloc source    */
  11. /* must include this copyright notice.                          */
  12. /*--------------------------------------------------------------*/
  13.  
  14. /*------------------------[ jmalloc.h ]----------------------------*/
  15. /*                   main header file for jmalloc                  */
  16. /*-----------------------------------------------------------------*/
  17.  
  18. /*--------------------------------------------------------------*/
  19. /*---------------------------[ defines ]------------------------*/
  20. /*--------------------------------------------------------------*/
  21. #ifndef _jmalloc
  22. #   define _jmalloc
  23.  
  24. #define FALSE 0
  25. #define TRUE 1
  26.  
  27. #define CKBYT 1
  28. #define DIRTY 2
  29.  
  30. /*--------------------------------------------------------------*/
  31. /*------------------------[ structures ]------------------------*/
  32. /*--------------------------------------------------------------*/
  33.  
  34. typedef struct mlist
  35. {
  36.     struct mlist *NextLink;         /* link to next struct */
  37.     char *MAddr;                    /* address assigned    */
  38.     unsigned MSize;                 /* size allocated      */
  39.     char MFile[20];                 /* Allocation file name */
  40.     int MLine;                      /* Allocation line number */
  41. } MLINK;
  42.  
  43. /*--------------------------------------------------------------*/
  44. /*--------------------[ public prototypes ]---------------------*/
  45. /*--------------------------------------------------------------*/
  46.  
  47. #ifdef __cplusplus
  48.    extern   "C"   {
  49. #endif
  50.  
  51. void db_prn(char *fmt, ...);
  52. #define DBUG_ENTER(a)
  53. #define DBUG_RETURN(a) return(a)
  54. #define DBUG_PRINT(a, b) db_prn b
  55. #define DBUG_PUSH(a)
  56. #define DBUG_VOID_RETURN return
  57.  
  58. #define JCheckStr(a) j_checkstr((a))
  59.  
  60. int j_checkstr(MLINK *str);
  61.  
  62. #ifdef DBUG
  63.  
  64. #define dr(a) j_deref(a, __FILE__, __LINE__)
  65.  
  66. #define JStrnSet(a, b, c) j_strnset((a), (b), (c), __FILE__, __LINE__)
  67. #define JStrDup(a) j_strdup((a), __FILE__, __LINE__)
  68. #define JStrCat(a, b) j_strcat((a), (b), __FILE__, __LINE__)
  69. #define JMalloc(a) j_malloc((a), __FILE__, __LINE__)
  70. #define JCalloc(a, b) j_calloc((a), (b), __FILE__, __LINE__)
  71. #define AStrCpy(a, b) a_strcpy((a), (b), sizeof (a), __FILE__, __LINE__)
  72. #define AStrCat(a, b) a_strcat((a), (b), sizeof (a), __FILE__, __LINE__)
  73. #define AStrnCpy(a, b, c) a_strncpy((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  74. #define AStrnSet(a, b, c) a_strnset((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  75. #define JFree(a) j_free(a, __FILE__, __LINE__)
  76. #define JStrCpy(a, b) j_strcpy((a), (b), __FILE__, __LINE__)
  77. #define JStrnCpy(a, b, c) j_strncpy((a), (b), (c), __FILE__, __LINE__)
  78. #define JMemCpy(a, b, c) j_memcpy((a), (b), (c), __FILE__, __LINE__)
  79. #define JMemSet(a, b, c) j_memset((a), (b), (c), __FILE__, __LINE__)
  80. #define JMemcheck(a) j_memcheck((a))
  81. #define AMemCpy(a, b, c) a_memcpy((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  82. #define AMemSet(a, b, c) a_memset((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  83. #define JRealloc(a, b) j_realloc((a), (b), __FILE__, __LINE__)
  84.  
  85. void *j_deref(void *a, char *file, int line);
  86. char *j_strnset(char *str, int ch, size_t n, char *file, int line);
  87. char *j_strdup(char *str, char *file, int line);
  88. char *j_strcat(char *__dest, char *__src, char *file, int line);
  89. void *j_malloc(unsigned size, char *file, int line);
  90. void *j_calloc(unsigned size, unsigned sizeach, char *file, int line);
  91. int j_memcheck(int CheckFree);
  92. void j_free(void *AllocAddr, char *file, int line);
  93. char *j_strcpy(char *__dest, const char *__src, char *file, int line);
  94. char *j_strncpy(char *__dest, const char *__src, size_t maxlen, char *file,
  95.                 int line);
  96. void *j_realloc(void *addr, unsigned Size, char *file, int line);
  97. void *j_memset(void *dest, int ch, size_t n, char *file, int line);
  98. void *j_memcpy(void *dest, const void *src, size_t n, char *file, int line);
  99. char *a_strcpy(char *__dest, const char *__src, int size, char *file,
  100.                int line);
  101. char*a_strcat(char *dest, const char *src, int size, char *file, int line);
  102. void *a_memcpy(void *dest, const void *src, size_t n, int size, char *file,
  103.              int line);
  104. void *a_memset(void *dest, int ch, size_t n, int size, char *file, int line);
  105. char *a_strncpy(char *__dest, const char *__src, size_t maxlen, int size,
  106.     char *file, int line);
  107. char *a_strnset(char *str, int ch, size_t n, int size, char *file, int line);
  108.  
  109.  
  110. #else
  111.  
  112. #define dr(a) (a)
  113.  
  114. #define JStrnSet(a, b, c) strnset((a), (b), (c))
  115. #define JStrDup(a) strdup((a))
  116. #define JStrCat(a, b) strcat((a), (b))
  117. #define JMalloc(a) malloc((a))
  118. #define JCalloc(a, b) calloc((a), (b))
  119. #define JFree(a) free(a)
  120. #define JStrCpy(a, b) strcpy((a), (b))
  121. #define JStrnCpy(a, b, c) strcpy((a), (b), (c))
  122. #define JMemCpy(a, b, c) memcpy((a), (b), (c))
  123. #define JMemSet(a, b, c) memset((a), (b), (c))
  124. #define JMemcheck(a)
  125. #define JRealloc(a, b) realloc((a), (b))
  126.  
  127. #define AStrCpy(a, b) strcpy((a), (b))
  128. #define AStrCat(a, b) strcat((a), (b))
  129. #define AStrnCpy(a, b, c)  strncpy((a), (b), (c))
  130. #define AStrnSet(a, b, c), strnset((a), (b), (c))
  131. #define AMemCpy(a, b, c) memcpy((a), (b), (c))
  132. #define AMemSet(a, b, c) memset((a), (b), (c))
  133.  
  134. #endif
  135.  
  136. #ifdef __cplusplus
  137.    }
  138. #endif
  139.  
  140. /*--------------------------------------------------------------*/
  141. /*---------------------[ public variables ]---------------------*/
  142. /*--------------------------------------------------------------*/
  143.  
  144. extern MLINK *MalTop;
  145. #endif
  146.