]> jfr.im git - irc/quakenet/newserv.git/blame - core/nsmalloc.h
initial commit - patricia nick index
[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);
34da4416 23
24#define MAXPOOL 100
25
ed24756c
CP
26struct nsminfo {
27 struct nsminfo *next;
28 struct nsminfo *prev;
29
30 size_t size;
31 char data[];
32};
33
34struct nsmpool {
35 struct nsminfo first;
36
37 unsigned long count;
38 size_t size;
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),
271ef2d2
CP
64} endpools()
65
66#undef pool
67#undef beginpools
68#undef endpools
69
70#endif