File: runmalloc.h

package info (click to toggle)
ircd 2.10.02-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 2,228 kB
  • ctags: 2,087
  • sloc: ansic: 29,122; makefile: 664; sh: 307; perl: 18
file content (66 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * runmalloc.h
 *
 * (C) Copyright 1996 - 1997, Carlo Wood (carlo@runaway.xs4all.nl)
 *
 * Headerfile of runmalloc.c
 *
 */

#ifndef RUNMALLOC_H
#define RUNMALLOC_H

#ifdef DEBUGMALLOC

#if defined(MEMMAGICNUMS) && !defined(MEMSIZESTATS)
#define MEMSIZESTATS
#endif
#ifndef MEMLEAKSTATS
#undef MEMTIMESTATS
#endif

/*=============================================================================
 * Proto types
 */

#ifdef MEMLEAKSTATS
extern void *RunMalloc_memleak(size_t size, int line, const char *filename);
extern void *RunCalloc_memleak(size_t nmemb, size_t size,
                               int line, const char *filename);
extern void *RunRealloc_memleak(void *ptr, size_t size,
                                int line, const char *filename);
struct Client;
extern void report_memleak_stats(struct Client *sptr, int parc, char *parv[]);
#define RunMalloc(x) RunMalloc_memleak(x, __LINE__, __FILE__)
#define RunCalloc(x,y) RunCalloc_memleak(x,y, __LINE__, __FILE__)
#define RunRealloc(x,y) RunRealloc_memleak(x,y, __LINE__, __FILE__)
#else
extern void *RunMalloc(size_t size);
extern void *RunCalloc(size_t nmemb, size_t size);
extern void *RunRealloc(void *ptr, size_t size);
#endif
extern int RunFree_test(void *ptr);
extern void RunFree(void *ptr);
#ifdef MEMSIZESTATS
extern u_long get_alloc_cnt(void);
extern size_t get_mem_size(void);
#endif

#else /* !DEBUGMALLOC */

#include <stdlib.h>

#undef MEMSIZESTATS
#undef MEMMAGICNUMS
#undef MEMLEAKSTATS
#undef MEMTIMESTATS

#define Debug_malloc(x)
#define RunMalloc(x) malloc(x)
#define RunCalloc(x,y) calloc(x,y)
#define RunRealloc(x,y) realloc(x,y)
#define RunFree(x) free(x)

#endif /* DEBUGMALLOC */

#endif /* RUNMALLOC_H */