]> jfr.im git - irc/quakenet/newserv.git/blame - core/nsmalloc.h
free sstrings in trojanscan (left behind if db connect fails)
[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 {
36 struct nsminfo first;
37
38 unsigned long count;
39 size_t size;
40};
41
42extern struct nsmpool nsmpools[MAXPOOL];
43
271ef2d2
CP
44#endif
45
34da4416 46/* Pools here in the order they were created */
271ef2d2
CP
47
48beginpools() {
49 pool(AUTHEXT),
50 pool(CHANINDEX),
51 pool(BANS),
52 pool(CHANNEL),
53 pool(NICK),
54 pool(CHANSERVDB),
55 pool(SSTRING),
56 pool(AUTHTRACKER),
57 pool(PROXYSCAN),
58 pool(LUA),
59 pool(TROJANSCAN),
60 pool(NTERFACER),
76c8da69
CP
61 pool(SQLITE),
62 pool(PQSQL),
024c3d57 63 pool(PATRICIA),
84ca44e7 64 pool(PATRICIANICK),
7be67351
P
65 pool(GLINE),
66 pool(TRUSTS),
a85729f7 67 pool(SPAMSCAN2),
271ef2d2
CP
68} endpools()
69
70#undef pool
71#undef beginpools
72#undef endpools
73
74#endif