home *** CD-ROM | disk | FTP | other *** search
- /* $Header$ */
- /*
- * malloc.h: Debugging malloc utils.
- *
- */
- #ifndef _h_malloc
- #define _h_malloc
-
-
- #ifdef __STDC__
- # define P_(a) a
- #else
- # define P_(a) ()
- #endif /* __STDC__ */
-
- #ifdef __STDC__
- # ifndef _MEMALIGN_T
- # define _MEMALIGN_T
- typedef void *memalign_t;
- # endif /* _MEMALIGN_T */
- # ifndef _PTR_T
- # define _PTR_T
- typedef void *ptr_t;
- # endif /* _PTR_T */
- #else /* ! __STDC__ */
- # ifndef _PTR_T
- # define _PTR_T
- typedef char *ptr_t;
- # endif /* _PTR_T */
- # ifdef lint
- /* Fool lint to believe that Malloc returns aligned pointers... */
- # ifndef _MEMALIGN_T
- # define _MEMALIGN_T
- typedef union _memalign_t {
- char a; short b; int c; long d; float e; double f; union _memalign_t *g;
- } *memalign_t;
- # endif /* _MEMALIGN_T */
- # else
- # ifndef _MEMALIGN_T
- # define _MEMALIGN_T
- typedef char *memalign_t;
- # endif /* _MEMALIGN_T */
- # endif /* lint */
-
- #endif /* ! __STDC__ */
-
- /*
- * Memory allocation macros
- */
- #ifdef DEBUG
- # define malloc(a) (ptr_t) DebugMalloc(a, __FILE__, __LINE__)
- # define realloc(a, n) (ptr_t) DebugRealloc(a, n, __FILE__, __LINE__)
- # define calloc(a, n) (ptr_t) DebugCalloc(a, n, __FILE__, __LINE)
- # define free(a) DebugFree(a, __FILE__, __LINE__)
- # define MemPtr(a) DebugMemPtr(a, __FILE__, __LINE__)
- # define MemStat() DebugMemStat()
- # define MemChain() DebugMemChain()
- #else
- # define MemPtr(a)
- # define MemStat()
- # define MemChain()
- #endif /* DEBUG */
-
- #ifdef DEBUG
- extern memalign_t DebugMalloc P_((unsigned, char *, int));
- extern memalign_t DebugCalloc P_((unsigned, unsigned, char *, int));
- extern memalign_t DebugRealloc P_((ptr_t, unsigned, char *, int));
- extern memalign_t DebugFree P_((ptr_t, char *, int));
- extern unsigned DebugMemPtr P_((ptr_t, char *, int));
- extern unsigned DebugMemStat P_((void));
- extern memalign_t DebugMemChain P_((void));
- #endif
-
- #endif /* _h_malloc */
-