]> jfr.im git - irc/quakenet/newserv.git/blame - core/nsmalloc.h
fixes for clang
[irc/quakenet/newserv.git] / core / nsmalloc.h
CommitLineData
34da4416 1/* nsmalloc: Simple pooled malloc() thing. */
2
271ef2d2
CP
3#ifndef __NSMALLOC_H
4#define __NSMALLOC_H
5
6#ifdef __NSMALLOC_C
7#define pool(x) #x
ed24756c 8#define beginpools() char *nsmpoolnames[MAXPOOL] =
271ef2d2
CP
9#define endpools();
10#else
11#define pool(x) POOL_ ## x
64e3058f 12#define beginpools(x) typedef enum nsmallocpools
ed24756c 13#define endpools() nsmallocpools; extern char *nsmpoolnames[MAXPOOL];
271ef2d2 14
34da4416 15#include <stdlib.h>
16
17void *nsmalloc(unsigned int poolid, size_t size);
18void nsfree(unsigned int poolid, void *ptr);
19void nsfreeall(unsigned int poolid);
103521a1 20void nsexit(void);
48005496 21void *nsrealloc(unsigned int poolid, void *ptr, size_t size);
f8d5cfcf 22void nscheckfreeall(unsigned int poolid);
f358bcd6 23void *nscalloc(unsigned int poolid, size_t nmemb, size_t size);
34da4416 24
25#define MAXPOOL 100
26
ed24756c
CP
27struct nsminfo {
28 struct nsminfo *next;
29 struct nsminfo *prev;
30
31 size_t size;
32 char data[];
33};
34
35struct nsmpool {
ed24756c
CP
36 unsigned long count;
37 size_t size;
0555113a 38 struct nsminfo first;
ed24756c
CP
39};
40
41extern struct nsmpool nsmpools[MAXPOOL];
42
271ef2d2
CP
43#endif
44
34da4416 45/* Pools here in the order they were created */
271ef2d2
CP
46
47beginpools() {
48 pool(AUTHEXT),
49 pool(CHANINDEX),
50 pool(BANS),
51 pool(CHANNEL),
52 pool(NICK),
53 pool(CHANSERVDB),
54 pool(SSTRING),
55 pool(AUTHTRACKER),
56 pool(PROXYSCAN),
57 pool(LUA),
58 pool(TROJANSCAN),
59 pool(NTERFACER),
76c8da69
CP
60 pool(SQLITE),
61 pool(PQSQL),
024c3d57 62 pool(PATRICIA),
84ca44e7 63 pool(PATRICIANICK),
7be67351
P
64 pool(GLINE),
65 pool(TRUSTS),
a85729f7 66 pool(SPAMSCAN2),
96d8e39a 67 pool(ACHIEVEMENTS)
271ef2d2
CP
68} endpools()
69
70#undef pool
71#undef beginpools
72#undef endpools
73
74#endif