]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/nsmalloc.h
Merge.
[irc/quakenet/newserv.git] / core / nsmalloc.h
index 9d77a147e78b46cae238b65b2b81e8bf4e85ee15..c7c4729b9e22efb06e06008e4331e9d21b6a2c2a 100644 (file)
@@ -1,5 +1,17 @@
 /* nsmalloc: Simple pooled malloc() thing. */
 
+#ifndef __NSMALLOC_H
+#define __NSMALLOC_H
+
+#ifdef __NSMALLOC_C
+#define pool(x) #x
+#define beginpools() char *poolnames[MAXPOOL] =
+#define endpools();
+#else
+#define pool(x) POOL_ ## x
+#define beginpools(x) typedef enum nsmallocpools
+#define endpools() nsmallocpools;
+
 #include <stdlib.h>
 
 void *nsmalloc(unsigned int poolid, size_t size);
@@ -7,20 +19,32 @@ void nsfree(unsigned int poolid, void *ptr);
 void nsfreeall(unsigned int poolid);
 void nsexit(void);
 void *nsrealloc(unsigned int poolid, void *ptr, size_t size);
-int nspoolstats(unsigned int poolid, size_t *size, unsigned long *count);
+void nscheckfreeall(unsigned int poolid);
+void initnsmalloc(void);
 
 #define MAXPOOL                100
 
+#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
-#define POOL_AUTHTRACKER       7
-#define POOL_PROXYSCAN         8
-#define POOL_LUA               9
-#define POOL_TROJANSCAN                10
-#define POOL_NTERFACER         11
+
+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),
+} endpools()
+
+#undef pool
+#undef beginpools
+#undef endpools
+
+#endif