]> jfr.im git - irc/quakenet/newserv.git/blob - core/nsmalloc.h
Merge.
[irc/quakenet/newserv.git] / core / nsmalloc.h
1 /* nsmalloc: Simple pooled malloc() thing. */
2
3 #ifndef __NSMALLOC_H
4 #define __NSMALLOC_H
5
6 #ifdef __NSMALLOC_C
7 #define pool(x) #x
8 #define beginpools() char *poolnames[MAXPOOL] =
9 #define endpools();
10 #else
11 #define pool(x) POOL_ ## x
12 #define beginpools(x) typedef enum nsmallocpools
13 #define endpools() nsmallocpools;
14
15 #include <stdlib.h>
16
17 void *nsmalloc(unsigned int poolid, size_t size);
18 void nsfree(unsigned int poolid, void *ptr);
19 void nsfreeall(unsigned int poolid);
20 void nsexit(void);
21 void *nsrealloc(unsigned int poolid, void *ptr, size_t size);
22 void nscheckfreeall(unsigned int poolid);
23 void initnsmalloc(void);
24
25 #define MAXPOOL 100
26
27 #endif
28
29 /* Pools here in the order they were created */
30
31 beginpools() {
32 pool(AUTHEXT),
33 pool(CHANINDEX),
34 pool(BANS),
35 pool(CHANNEL),
36 pool(NICK),
37 pool(CHANSERVDB),
38 pool(SSTRING),
39 pool(AUTHTRACKER),
40 pool(PROXYSCAN),
41 pool(LUA),
42 pool(TROJANSCAN),
43 pool(NTERFACER),
44 } endpools()
45
46 #undef pool
47 #undef beginpools
48 #undef endpools
49
50 #endif