5b393613af93115596473900cac0198449224692
[ircu2.10.12-pk.git] / include / runmalloc.h
1 /*
2  * runmalloc.h
3  *
4  * (C) Copyright 1996 - 1997, Carlo Wood (carlo@runaway.xs4all.nl)
5  *
6  * Headerfile of runmalloc.c
7  *
8  */
9
10 #ifndef RUNMALLOC_H
11 #define RUNMALLOC_H
12
13 #ifdef DEBUGMALLOC
14
15 #if defined(MEMMAGICNUMS) && !defined(MEMSIZESTATS)
16 #define MEMSIZESTATS
17 #endif
18 #ifndef MEMLEAKSTATS
19 #undef MEMTIMESTATS
20 #endif
21
22 /*=============================================================================
23  * Proto types
24  */
25
26 #ifdef MEMLEAKSTATS
27 extern void *RunMalloc_memleak(size_t size, int line, const char *filename);
28 extern void *RunCalloc_memleak(size_t nmemb, size_t size,
29     int line, const char *filename);
30 extern void *RunRealloc_memleak(void *ptr, size_t size,
31     int line, const char *filename);
32 struct Client;
33 extern void report_memleak_stats(struct Client *sptr, int parc, char *parv[]);
34 #define RunMalloc(x) RunMalloc_memleak(x, __LINE__, __FILE__)
35 #define RunCalloc(x,y) RunCalloc_memleak(x,y, __LINE__, __FILE__)
36 #define RunRealloc(x,y) RunRealloc_memleak(x,y, __LINE__, __FILE__)
37 #else
38 extern void *RunMalloc(size_t size);
39 extern void *RunCalloc(size_t nmemb, size_t size);
40 extern void *RunRealloc(void *ptr, size_t size);
41 #endif
42 extern int RunFree_test(void *ptr);
43 extern void RunFree(void *ptr);
44 #ifdef MEMSIZESTATS
45 extern unsigned int get_alloc_cnt(void);
46 extern size_t get_mem_size(void);
47 #endif
48
49 #else /* !DEBUGMALLOC */
50
51 #include <stdlib.h>
52
53 #undef MEMSIZESTATS
54 #undef MEMMAGICNUMS
55 #undef MEMLEAKSTATS
56 #undef MEMTIMESTATS
57
58 #define Debug_malloc(x)
59 #define RunMalloc(x) malloc(x)
60 #define RunCalloc(x,y) calloc(x,y)
61 #define RunRealloc(x,y) realloc(x,y)
62 #define RunFree(x) free(x)
63
64 #endif /* DEBUGMALLOC */
65
66 #endif /* RUNMALLOC_H */