]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Use nsmalloc/nsfree for core/schedule.
authorGunnar Beutner <redacted>
Tue, 30 Jul 2013 16:56:21 +0000 (18:56 +0200)
committerGunnar Beutner <redacted>
Tue, 30 Jul 2013 16:56:21 +0000 (18:56 +0200)
core/nsmalloc.h
core/schedule.c
core/schedulealloc.c

index aa1e8432990e9888b83c33f198b688d380916cbb..9410d2837211c0fb13ffd55b5b16e19732507eb9 100644 (file)
@@ -68,7 +68,8 @@ beginpools() {
   pool(TRUSTS),
   pool(SPAMSCAN2),
   pool(ACHIEVEMENTS),
-  pool(CHANSTATS)
+  pool(CHANSTATS),
+  pool(SCHEDULE)
 } endpools()
 
 #undef pool
index e619f05ed8322a167dda2415ce03d9398afbb57b..a8986bbef85f2fb20b93cb4accf8d58677f3b90b 100644 (file)
@@ -27,7 +27,6 @@ int schedexes;
 void schedulestats(int hooknum, void *arg);
 
 void initschedule() {
-  initschedulealloc();
   events=NULL;
   schedadds=scheddels=schedexes=scheddelfast=0;
   registerhook(HOOK_CORE_STATSREQUEST, &schedulestats);
index 2929826b0d85e03e18a03daf329b79baa3b1a060..686af4ffec8ecce5e9aab166a8bad9bac06d19ae 100644 (file)
@@ -1,37 +1,13 @@
 /* schedulealloc.c */
 
 #include "schedule.h"
-#include <stdlib.h>
-
-#define ALLOCUNIT 100
-
-schedule *freescheds;
-
-void initschedulealloc() {
-  freescheds=NULL;
-}
+#include "nsmalloc.h"
 
 schedule *getschedule() {
-  int i;
-  schedule *sp;
-
-  if (freescheds==NULL) {
-    freescheds=(schedule *)malloc(ALLOCUNIT*sizeof(schedule));
-    for (i=0;i<ALLOCUNIT-1;i++) {
-      freescheds[i].callbackparam=(void *)&(freescheds[i+1]);
-    }
-    freescheds[ALLOCUNIT-1].callbackparam=NULL;
-  }
-
-  sp=freescheds;
-  freescheds=(schedule *)sp->callbackparam;
-
-  return sp;
+  return nsmalloc(POOL_SCHEDULE, sizeof(schedule));
 }
 
 void freeschedule(schedule *sp) {
-  sp->callbackparam=(void *)freescheds;
-  sp->callback=NULL;
-  freescheds=sp;
+  return nsfree(POOL_SCHEDULE, sp);
 }