4 * (C) Copyright 1996 - 1997, Carlo Wood (carlo@runaway.xs4all.nl)
6 * Headerfile of runmalloc.c
10 #ifndef INCLUDED_runmalloc_h
11 #define INCLUDED_runmalloc_h
12 #ifndef INCLUDED_config_h
15 #ifndef INCLUDED_sys_types_h
16 #include <sys/types.h> /* size_t */
17 #define INCLUDED_sys_types_h
20 typedef void (*OutOfMemoryHandler)(void);
22 extern void set_nomem_handler(OutOfMemoryHandler handler);
26 * we want to be able to test in DEBUGMODE without turning
27 * DEBUGMALLOC on, change in the config not in the code
29 #if defined(DEBUGMODE) && !defined(DEBUGMALLOC)
36 #if defined(MEMMAGICNUMS) && !defined(MEMSIZESTATS)
49 extern void *RunMalloc_memleak(size_t size, int line, const char *filename);
50 extern void *RunCalloc_memleak(size_t nmemb, size_t size,
51 int line, const char *filename);
52 extern void *RunRealloc_memleak(void *ptr, size_t size,
53 int line, const char *filename);
55 extern void report_memleak_stats(struct Client *sptr, int parc, char *parv[]);
56 #define MyMalloc(x) RunMalloc_memleak(x, __LINE__, __FILE__)
57 #define MyCalloc(x,y) RunCalloc_memleak(x,y, __LINE__, __FILE__)
58 #define MyRealloc(x,y) RunRealloc_memleak(x,y, __LINE__, __FILE__)
60 #else /* !MEMLEAKSTATS */
61 extern void *MyMalloc(size_t size);
62 extern void *MyCalloc(size_t nmemb, size_t size);
63 extern void *MyRealloc(void *ptr, size_t size);
64 #endif /* MEMLEAKSTATS */
66 extern int MyFree_test(void *ptr);
67 extern void MyFree(void *ptr);
70 extern unsigned int get_alloc_cnt(void);
71 extern size_t get_mem_size(void);
74 #else /* !DEBUGMALLOC */
76 #ifndef INCLUDED_stdlib_h
78 #define INCLUDED_stdlib_h
86 #define MyFree(x) do { free((x)); (x) = 0; } while(0)
87 #define Debug_malloc(x)
88 extern void* MyMalloc(size_t size);
89 extern void* MyCalloc(size_t nelem, size_t size);
90 extern void* MyRealloc(void* x, size_t size);
92 #endif /* DEBUGMALLOC */
94 #endif /* INCLUDED_runmalloc_h */