X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/103521a179b174e7aa878e07f4c58f759ac65366..refs/pull/83/head:/core/nsmalloc.h diff --git a/core/nsmalloc.h b/core/nsmalloc.h index 29e5df59..9410d283 100644 --- a/core/nsmalloc.h +++ b/core/nsmalloc.h @@ -1,19 +1,79 @@ /* nsmalloc: Simple pooled malloc() thing. */ +#ifndef __NSMALLOC_H +#define __NSMALLOC_H + +#ifdef __NSMALLOC_C +#define pool(x) #x +#define beginpools() char *nsmpoolnames[MAXPOOL] = +#define endpools(); +#else +#define pool(x) POOL_ ## x +#define beginpools(x) typedef enum nsmallocpools +#define endpools() nsmallocpools; extern char *nsmpoolnames[MAXPOOL]; + #include +#include void *nsmalloc(unsigned int poolid, size_t size); void nsfree(unsigned int poolid, void *ptr); void nsfreeall(unsigned int poolid); +void nsinit(void); void nsexit(void); +void *nsrealloc(unsigned int poolid, void *ptr, size_t size); +void nscheckfreeall(unsigned int poolid); +void *nscalloc(unsigned int poolid, size_t nmemb, size_t size); #define MAXPOOL 100 +#define REDZONE_MAGIC 0x243653E957851F68ULL +struct nsminfo { + struct nsminfo *next; + struct nsminfo *prev; + + size_t size; + uint64_t redzone; + char data[]; +}; + +struct nsmpool { + unsigned long count; + size_t size; + struct nsminfo *blocks; +}; + +extern struct nsmpool nsmpools[MAXPOOL]; + +#endif /* Pools here in the order they were created */ -#define POOL_AUTHEXT 0 -#define POOL_CHANINDEX 1 -#define POOL_BANS 2 -#define POOL_CHANNEL 3 -#define POOL_NICK 4 -#define POOL_CHANSERVDB 5 -#define POOL_SSTRING 6 + +beginpools() { + pool(AUTHEXT), + pool(CHANINDEX), + pool(BANS), + pool(CHANNEL), + pool(NICK), + pool(CHANSERVDB), + pool(SSTRING), + pool(AUTHTRACKER), + pool(PROXYSCAN), + pool(LUA), + pool(TROJANSCAN), + pool(NTERFACER), + pool(SQLITE), + pool(PQSQL), + pool(PATRICIA), + pool(PATRICIANICK), + pool(GLINE), + pool(TRUSTS), + pool(SPAMSCAN2), + pool(ACHIEVEMENTS), + pool(CHANSTATS), + pool(SCHEDULE) +} endpools() + +#undef pool +#undef beginpools +#undef endpools + +#endif