]> jfr.im git - irc/quakenet/newserv.git/blobdiff - core/nsmalloc.c
gline playground
[irc/quakenet/newserv.git] / core / nsmalloc.c
index 901987cc67fa6f5eae6b276496177711d624038d..0575c55c05f913f9ab21388876d6c2719d5b50d4 100644 (file)
@@ -1,6 +1,7 @@
 /* nsmalloc: Simple pooled malloc() thing. */
 
 #include <stdlib.h>
+#include <string.h>
 
 #include "nsmalloc.h"
 #define __NSMALLOC_C
@@ -39,6 +40,19 @@ void *nsmalloc(unsigned int poolid, size_t size) {
   return (void *)nsmp->data;
 }
 
+void *nscalloc(unsigned int poolid, size_t nmemb, size_t size) {
+  size_t total = nmemb * size;
+  void *m;
+
+  m = nsmalloc(poolid, total);
+  if(!m)
+    return NULL;
+
+  memset(m, 0, total);
+
+  return m;
+}
+
 /* we dump core on ptr == NULL */
 void nsfree(unsigned int poolid, void *ptr) {
   struct nsminfo *nsmp;
@@ -136,6 +150,10 @@ void *nsmalloc(unsigned int poolid, size_t size) {
   return malloc(size);
 }
 
+void *nscalloc(unsigned int poolid, size_t nmemb, size_t size) {
+  return calloc(nmemb, size);
+}
+
 void *nsrealloc(unsigned int poolid, void *ptr, size_t size) {
   return realloc(ptr, size);
 }