summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Makefile.in24
-rw-r--r--src/channel.c28
-rw-r--r--src/channel_mode.c8
-rw-r--r--src/client.c23
-rw-r--r--src/conf.c15
-rwxr-xr-xsrc/conf_class.c11
-rw-r--r--src/dbuf.c11
-rw-r--r--src/hash.c21
-rw-r--r--src/irc_res.c11
-rw-r--r--src/ircd.c4
-rw-r--r--src/list.c17
-rw-r--r--src/s_auth.c13
-rw-r--r--src/watch.c14
14 files changed, 110 insertions, 94 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f79e405..5971cab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,8 +9,7 @@ ircd_LDFLAGS = -export-dynamic
ircd_LDADD = $(LIBLTDL)
ircd_DEPENDENCIES = $(LTDLDEPS)
-ircd_SOURCES = balloc.c \
- channel.c \
+ircd_SOURCES = channel.c \
channel_mode.c \
client.c \
conf.c \
@@ -35,6 +34,7 @@ ircd_SOURCES = balloc.c \
log.c \
match.c \
memory.c \
+ mempool.c \
modules.c \
motd.c \
rng_mt.c \
diff --git a/src/Makefile.in b/src/Makefile.in
index cabccfc..838791b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -66,15 +66,15 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(sbindir)"
PROGRAMS = $(sbin_PROGRAMS)
-am_ircd_OBJECTS = balloc.$(OBJEXT) channel.$(OBJEXT) \
- channel_mode.$(OBJEXT) client.$(OBJEXT) conf.$(OBJEXT) \
- conf_class.$(OBJEXT) conf_db.$(OBJEXT) conf_parser.$(OBJEXT) \
- conf_lexer.$(OBJEXT) dbuf.$(OBJEXT) event.$(OBJEXT) \
- fdlist.$(OBJEXT) getopt.$(OBJEXT) hash.$(OBJEXT) \
- hook.$(OBJEXT) hostmask.$(OBJEXT) irc_res.$(OBJEXT) \
- irc_reslib.$(OBJEXT) irc_string.$(OBJEXT) ircd.$(OBJEXT) \
- ircd_signal.$(OBJEXT) list.$(OBJEXT) listener.$(OBJEXT) \
- log.$(OBJEXT) match.$(OBJEXT) memory.$(OBJEXT) \
+am_ircd_OBJECTS = channel.$(OBJEXT) channel_mode.$(OBJEXT) \
+ client.$(OBJEXT) conf.$(OBJEXT) conf_class.$(OBJEXT) \
+ conf_db.$(OBJEXT) conf_parser.$(OBJEXT) conf_lexer.$(OBJEXT) \
+ dbuf.$(OBJEXT) event.$(OBJEXT) fdlist.$(OBJEXT) \
+ getopt.$(OBJEXT) hash.$(OBJEXT) hook.$(OBJEXT) \
+ hostmask.$(OBJEXT) irc_res.$(OBJEXT) irc_reslib.$(OBJEXT) \
+ irc_string.$(OBJEXT) ircd.$(OBJEXT) ircd_signal.$(OBJEXT) \
+ list.$(OBJEXT) listener.$(OBJEXT) log.$(OBJEXT) \
+ match.$(OBJEXT) memory.$(OBJEXT) mempool.$(OBJEXT) \
modules.$(OBJEXT) motd.$(OBJEXT) rng_mt.$(OBJEXT) \
numeric.$(OBJEXT) packet.$(OBJEXT) parse.$(OBJEXT) \
s_bsd_epoll.$(OBJEXT) s_bsd_poll.$(OBJEXT) \
@@ -270,8 +270,7 @@ AM_CPPFLAGS = $(LTDLINCL) -I$(top_srcdir)/include
ircd_LDFLAGS = -export-dynamic
ircd_LDADD = $(LIBLTDL)
ircd_DEPENDENCIES = $(LTDLDEPS)
-ircd_SOURCES = balloc.c \
- channel.c \
+ircd_SOURCES = channel.c \
channel_mode.c \
client.c \
conf.c \
@@ -296,6 +295,7 @@ ircd_SOURCES = balloc.c \
log.c \
match.c \
memory.c \
+ mempool.c \
modules.c \
motd.c \
rng_mt.c \
@@ -416,7 +416,6 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/balloc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/channel_mode.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@
@@ -442,6 +441,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/match.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mempool.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/modules.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric.Po@am__quote@
diff --git a/src/channel.c b/src/channel.c
index e6b0e46..c79ecdd 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -41,14 +41,14 @@
#include "send.h"
#include "event.h"
#include "memory.h"
-#include "balloc.h"
+#include "mempool.h"
struct config_channel_entry ConfigChannel;
dlink_list global_channel_list = { NULL, NULL, 0 };
-BlockHeap *ban_heap; /*! \todo ban_heap shouldn't be a global var */
+mp_pool_t *ban_pool; /*! \todo ban_pool shouldn't be a global var */
-static BlockHeap *member_heap = NULL;
-static BlockHeap *channel_heap = NULL;
+static mp_pool_t *member_pool = NULL;
+static mp_pool_t *channel_pool = NULL;
static char buf[IRCD_BUFSIZE];
static char modebuf[MODEBUFLEN];
@@ -64,9 +64,9 @@ init_channels(void)
add_capability("IE", CAP_IE, 1);
add_capability("CHW", CAP_CHW, 1);
- channel_heap = BlockHeapCreate("channel", sizeof(struct Channel), CHANNEL_HEAP_SIZE);
- ban_heap = BlockHeapCreate("ban", sizeof(struct Ban), BAN_HEAP_SIZE);
- member_heap = BlockHeapCreate("member", sizeof(struct Membership), CHANNEL_HEAP_SIZE*2);
+ channel_pool = mp_pool_new(sizeof(struct Channel), MP_CHUNK_SIZE_CHANNEL);
+ ban_pool = mp_pool_new(sizeof(struct Ban), MP_CHUNK_SIZE_BAN);
+ member_pool = mp_pool_new(sizeof(struct Membership), MP_CHUNK_SIZE_MEMBER);
}
/*! \brief adds a user to a channel by adding another link to the
@@ -113,7 +113,9 @@ add_user_to_channel(struct Channel *chptr, struct Client *who,
chptr->last_join_time = CurrentTime;
}
- ms = BlockHeapAlloc(member_heap);
+ ms = mp_pool_get(member_pool);
+ memset(ms, 0, sizeof(*ms));
+
ms->client_p = who;
ms->chptr = chptr;
ms->flags = flags;
@@ -135,7 +137,7 @@ remove_user_from_channel(struct Membership *member)
dlinkDelete(&member->channode, &chptr->members);
dlinkDelete(&member->usernode, &client_p->channel);
- BlockHeapFree(member_heap, member);
+ mp_pool_release(member);
if (chptr->members.head == NULL)
destroy_channel(chptr);
@@ -339,7 +341,7 @@ remove_ban(struct Ban *bptr, dlink_list *list)
MyFree(bptr->host);
MyFree(bptr->who);
- BlockHeapFree(ban_heap, bptr);
+ mp_pool_release(bptr);
}
/* free_channel_list()
@@ -371,7 +373,9 @@ make_channel(const char *chname)
assert(!EmptyString(chname));
- chptr = BlockHeapAlloc(channel_heap);
+ chptr = mp_pool_get(channel_pool);
+
+ memset(chptr, 0, sizeof(*chptr));
/* doesn't hurt to set it here */
chptr->channelts = CurrentTime;
@@ -404,7 +408,7 @@ destroy_channel(struct Channel *chptr)
dlinkDelete(&chptr->node, &global_channel_list);
hash_del_channel(chptr);
- BlockHeapFree(channel_heap, chptr);
+ mp_pool_release(chptr);
}
/*!
diff --git a/src/channel_mode.c b/src/channel_mode.c
index 808d186..de5b014 100644
--- a/src/channel_mode.c
+++ b/src/channel_mode.c
@@ -40,7 +40,7 @@
#include "whowas.h"
#include "event.h"
#include "memory.h"
-#include "balloc.h"
+#include "mempool.h"
#include "log.h"
#include "parse.h"
@@ -107,7 +107,7 @@ static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6, CAP_HOPS };
static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6 };
#endif
static struct ChCapCombo chcap_combos[NCHCAP_COMBOS];
-extern BlockHeap *ban_heap;
+extern mp_pool_t *ban_pool;
/* XXX check_string is propably not longer required in add_id and del_id */
@@ -224,8 +224,8 @@ add_id(struct Client *client_p, struct Channel *chptr, char *banid, int type)
}
}
- ban_p = BlockHeapAlloc(ban_heap);
-
+ ban_p = mp_pool_get(ban_pool);
+ memset(ban_p, 0, sizeof(*ban_p));
ban_p->name = xstrdup(name);
ban_p->username = xstrdup(user);
ban_p->host = xstrdup(host);
diff --git a/src/client.c b/src/client.c
index 0ec54a3..d7d307b 100644
--- a/src/client.c
+++ b/src/client.c
@@ -45,8 +45,8 @@
#include "s_user.h"
#include "dbuf.h"
#include "memory.h"
+#include "mempool.h"
#include "hostmask.h"
-#include "balloc.h"
#include "listener.h"
#include "irc_res.h"
#include "userhost.h"
@@ -64,8 +64,8 @@ dlink_list oper_list = {NULL, NULL, 0};
static EVH check_pings;
-static BlockHeap *client_heap = NULL;
-static BlockHeap *lclient_heap = NULL;
+static mp_pool_t *client_pool = NULL;
+static mp_pool_t *lclient_pool = NULL;
static dlink_list dead_list = { NULL, NULL, 0};
static dlink_list abort_list = { NULL, NULL, 0};
@@ -89,8 +89,8 @@ init_client(void)
/* start off the check ping event .. -- adrian
* Every 30 seconds is plenty -- db
*/
- client_heap = BlockHeapCreate("client", sizeof(struct Client), CLIENT_HEAP_SIZE);
- lclient_heap = BlockHeapCreate("local client", sizeof(struct LocalUser), LCLIENT_HEAP_SIZE);
+ client_pool = mp_pool_new(sizeof(struct Client), MP_CHUNK_SIZE_CLIENT);
+ lclient_pool = mp_pool_new(sizeof(struct LocalUser), MP_CHUNK_SIZE_LCLIENT);
eventAdd("check_pings", check_pings, NULL, 5);
}
@@ -112,12 +112,17 @@ init_client(void)
struct Client *
make_client(struct Client *from)
{
- struct Client *client_p = BlockHeapAlloc(client_heap);
+ struct Client *client_p = mp_pool_get(client_pool);
+
+ memset(client_p, 0, sizeof(*client_p));
if (from == NULL)
{
client_p->from = client_p; /* 'from' of local client is self! */
- client_p->localClient = BlockHeapAlloc(lclient_heap);
+ client_p->localClient = mp_pool_get(lclient_pool);
+
+ memset(client_p->localClient, 0, sizeof(*client_p->localClient));
+
client_p->localClient->since = CurrentTime;
client_p->localClient->lasttime = CurrentTime;
client_p->localClient->firsttime = CurrentTime;
@@ -183,10 +188,10 @@ free_client(struct Client *client_p)
dbuf_clear(&client_p->localClient->buf_recvq);
dbuf_clear(&client_p->localClient->buf_sendq);
- BlockHeapFree(lclient_heap, client_p->localClient);
+ mp_pool_release(client_p->localClient);
}
- BlockHeapFree(client_heap, client_p);
+ mp_pool_release(client_p);
}
/*
diff --git a/src/conf.c b/src/conf.c
index d7119db..3ec7965 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -25,7 +25,6 @@
#include "stdinc.h"
#include "list.h"
#include "ircd_defs.h"
-#include "balloc.h"
#include "conf.h"
#include "s_serv.h"
#include "resv.h"
@@ -45,6 +44,7 @@
#include "send.h"
#include "s_gline.h"
#include "memory.h"
+#include "mempool.h"
#include "irc_res.h"
#include "userhost.h"
#include "s_user.h"
@@ -104,7 +104,7 @@ struct ip_entry
};
static struct ip_entry *ip_hash_table[IP_HASH_SIZE];
-static BlockHeap *ip_entry_heap = NULL;
+static mp_pool_t *ip_entry_pool = NULL;
static int ip_entries_count = 0;
@@ -654,7 +654,7 @@ attach_iline(struct Client *client_p, struct MaskItem *conf)
void
init_ip_hash_table(void)
{
- ip_entry_heap = BlockHeapCreate("ip", sizeof(struct ip_entry),
+ ip_entry_pool = mp_pool_new(sizeof(struct ip_entry),
2 * hard_fdlimit);
memset(ip_hash_table, 0, sizeof(ip_hash_table));
}
@@ -704,7 +704,8 @@ find_or_add_ip(struct irc_ssaddr *ip_in)
if (ip_entries_count >= 2 * hard_fdlimit)
garbage_collect_ip_entries();
- newptr = BlockHeapAlloc(ip_entry_heap);
+ newptr = mp_pool_get(ip_entry_pool);
+ memset(newptr, 0, sizeof(*newptr));
ip_entries_count++;
memcpy(&newptr->ip, ip_in, sizeof(struct irc_ssaddr));
@@ -762,7 +763,7 @@ remove_one_ip(struct irc_ssaddr *ip_in)
else
ip_hash_table[hash_index] = ptr->next;
- BlockHeapFree(ip_entry_heap, ptr);
+ mp_pool_release(ptr);
ip_entries_count--;
return;
}
@@ -865,7 +866,7 @@ garbage_collect_ip_entries(void)
last_ptr->next = ptr->next;
else
ip_hash_table[i] = ptr->next;
- BlockHeapFree(ip_entry_heap, ptr);
+ mp_pool_release(ptr);
ip_entries_count--;
}
else
@@ -1077,7 +1078,7 @@ find_matching_name_conf(enum maskitem_type type, const char *name, const char *u
DLINK_FOREACH(ptr, list_p->head)
{
conf = ptr->data;
- assert(conf->regexpname);
+ assert(conf->regexuser);
if (!ircd_pcre_exec(conf->regexuser, name))
return conf;
diff --git a/src/conf_class.c b/src/conf_class.c
index 62da883..1a9824f 100755
--- a/src/conf_class.c
+++ b/src/conf_class.c
@@ -27,7 +27,6 @@
#include "stdinc.h"
#include "list.h"
#include "ircd_defs.h"
-#include "balloc.h"
#include "conf.h"
#include "s_serv.h"
#include "resv.h"
@@ -111,7 +110,7 @@ get_client_class(const dlink_list *const list)
const struct MaskItem *conf = ptr->data;
assert(conf->class);
- assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
+ assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
return conf->class->name;
}
@@ -127,8 +126,8 @@ get_client_ping(const dlink_list *const list)
if ((ptr = list->head)) {
const struct MaskItem *conf = ptr->data;
- assert(aconf->class);
- assert(aconf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
+ assert(conf->class);
+ assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
return conf->class->ping_freq;
}
@@ -145,7 +144,7 @@ get_sendq(const dlink_list *const list)
const struct MaskItem *conf = ptr->data;
assert(conf->class);
- assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
+ assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
return conf->class->max_sendq;
}
@@ -162,7 +161,7 @@ get_recvq(const dlink_list *const list)
const struct MaskItem *conf = ptr->data;
assert(conf->class);
- assert(conf->type & (CONF_OPERATOR | CONF_CLIENT | CONF_SERVER));
+ assert(conf->type & (CONF_OPER | CONF_CLIENT | CONF_SERVER));
return conf->class->max_recvq;
}
diff --git a/src/dbuf.c b/src/dbuf.c
index 1271b86..9004dbe 100644
--- a/src/dbuf.c
+++ b/src/dbuf.c
@@ -24,23 +24,24 @@
#include "stdinc.h"
#include "list.h"
-#include "balloc.h"
#include "dbuf.h"
#include "memory.h"
+#include "mempool.h"
-static BlockHeap *dbuf_heap;
+static mp_pool_t *dbuf_pool;
void
dbuf_init(void)
{
- dbuf_heap = BlockHeapCreate("dbuf", sizeof(struct dbuf_block), DBUF_HEAP_SIZE);
+ dbuf_pool = mp_pool_new(sizeof(struct dbuf_block), MP_CHUNK_SIZE_DBUF);
}
static struct dbuf_block *
dbuf_alloc(struct dbuf_queue *qptr)
{
- struct dbuf_block *block = BlockHeapAlloc(dbuf_heap);
+ struct dbuf_block *block = mp_pool_get(dbuf_pool);
+ memset(block, 0, sizeof(*block));
dlinkAddTail(block, make_dlink_node(), &qptr->blocks);
return block;
}
@@ -101,7 +102,7 @@ dbuf_delete(struct dbuf_queue *qptr, size_t count)
count -= first->size;
dlinkDelete(ptr, &qptr->blocks);
free_dlink_node(ptr);
- BlockHeapFree(dbuf_heap, first);
+ mp_pool_release(first);
}
/* ..then remove data from the beginning of the queue */
diff --git a/src/hash.c b/src/hash.c
index 2752c21..45b410b 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -24,7 +24,6 @@
#include "stdinc.h"
#include "list.h"
-#include "balloc.h"
#include "conf.h"
#include "channel.h"
#include "channel_mode.h"
@@ -39,12 +38,13 @@
#include "numeric.h"
#include "send.h"
#include "memory.h"
+#include "mempool.h"
#include "dbuf.h"
#include "s_user.h"
-static BlockHeap *userhost_heap = NULL;
-static BlockHeap *namehost_heap = NULL;
+static mp_pool_t *userhost_pool = NULL;
+static mp_pool_t *namehost_pool = NULL;
static unsigned int hashf_xor_key = 0;
@@ -74,8 +74,8 @@ init_hash(void)
* should be a good close approximation anyway
* - Dianora
*/
- userhost_heap = BlockHeapCreate("userhost", sizeof(struct UserHost), CLIENT_HEAP_SIZE);
- namehost_heap = BlockHeapCreate("namehost", sizeof(struct NameHost), CLIENT_HEAP_SIZE);
+ userhost_pool = mp_pool_new(sizeof(struct UserHost), MP_CHUNK_SIZE_CLIENT);
+ namehost_pool = mp_pool_new(sizeof(struct NameHost), MP_CHUNK_SIZE_CLIENT);
hashf_xor_key = genrand_int32() % 256; /* better than nothing --adx */
}
@@ -620,7 +620,9 @@ find_or_add_userhost(const char *host)
if ((userhost = hash_find_userhost(host)) != NULL)
return userhost;
- userhost = BlockHeapAlloc(userhost_heap);
+ userhost = mp_pool_get(userhost_pool);
+
+ memset(userhost, 0, sizeof(*userhost));
strlcpy(userhost->host, host, sizeof(userhost->host));
hash_add_userhost(userhost);
@@ -671,7 +673,8 @@ add_user_host(const char *user, const char *host, int global)
}
}
- nameh = BlockHeapAlloc(namehost_heap);
+ nameh = mp_pool_get(namehost_pool);
+ memset(nameh, 0, sizeof(*nameh));
strlcpy(nameh->name, user, sizeof(nameh->name));
nameh->gcount = 1;
@@ -730,13 +733,13 @@ delete_user_host(const char *user, const char *host, int global)
if (nameh->gcount == 0 && nameh->lcount == 0)
{
dlinkDelete(&nameh->node, &found_userhost->list);
- BlockHeapFree(namehost_heap, nameh);
+ mp_pool_release(nameh);
}
if (dlink_list_length(&found_userhost->list) == 0)
{
hash_del_userhost(found_userhost);
- BlockHeapFree(userhost_heap, found_userhost);
+ mp_pool_release(found_userhost);
}
return;
diff --git a/src/irc_res.c b/src/irc_res.c
index 200b68d..2963ee1 100644
--- a/src/irc_res.c
+++ b/src/irc_res.c
@@ -21,7 +21,6 @@
#include "stdinc.h"
#include "list.h"
-#include "balloc.h"
#include "client.h"
#include "event.h"
#include "irc_string.h"
@@ -35,6 +34,7 @@
#include "s_misc.h"
#include "send.h"
#include "memory.h"
+#include "mempool.h"
#include "irc_res.h"
#include "irc_reslib.h"
@@ -91,7 +91,7 @@ struct reslist
static fde_t ResolverFileDescriptor;
static dlink_list request_list = { NULL, NULL, 0 };
-static BlockHeap *dns_heap = NULL;
+static mp_pool_t *dns_pool = NULL;
static void rem_request(struct reslist *);
static struct reslist *make_request(dns_callback_fnc, void *);
@@ -244,7 +244,7 @@ start_resolver(void)
void
init_resolver(void)
{
- dns_heap = BlockHeapCreate("dns", sizeof(struct reslist), DNS_HEAP_SIZE);
+ dns_pool = mp_pool_new(sizeof(struct reslist), MP_CHUNK_SIZE_DNS);
memset(&ResolverFileDescriptor, 0, sizeof(fde_t));
start_resolver();
}
@@ -271,7 +271,7 @@ rem_request(struct reslist *request)
dlinkDelete(&request->node, &request_list);
MyFree(request->name);
- BlockHeapFree(dns_heap, request);
+ mp_pool_release(request);
}
/*
@@ -280,8 +280,9 @@ rem_request(struct reslist *request)
static struct reslist *
make_request(dns_callback_fnc callback, void *ctx)
{
- struct reslist *request = BlockHeapAlloc(dns_heap);
+ struct reslist *request = mp_pool_get(dns_pool);
+ memset(request, 0, sizeof(*request));
request->sentat = CurrentTime;
request->retries = 3;
request->resend = 1;
diff --git a/src/ircd.c b/src/ircd.c
index a593841..30e0ea2 100644
--- a/src/ircd.c
+++ b/src/ircd.c
@@ -53,9 +53,9 @@
#include "whowas.h"
#include "modules.h"
#include "memory.h"
+#include "mempool.h"
#include "hook.h"
#include "ircd_getopt.h"
-#include "balloc.h"
#include "motd.h"
#include "supported.h"
#include "watch.h"
@@ -548,7 +548,7 @@ main(int argc, char *argv[])
/* Check if there is pidfile and daemon already running */
check_pidfile(pidFileName);
- initBlockHeap();
+ mp_pool_init();
init_dlink_nodes();
init_callbacks();
initialize_message_files();
diff --git a/src/list.c b/src/list.c
index 2850d46..6110e14 100644
--- a/src/list.c
+++ b/src/list.c
@@ -24,9 +24,9 @@
#include "stdinc.h"
#include "list.h"
-#include "balloc.h"
+#include "mempool.h"
-static BlockHeap *dnode_heap;
+static mp_pool_t *dnode_pool;
/* init_dlink_nodes()
@@ -38,7 +38,7 @@ static BlockHeap *dnode_heap;
void
init_dlink_nodes(void)
{
- dnode_heap = BlockHeapCreate("dlink node", sizeof(dlink_node), DNODE_HEAP_SIZE);
+ dnode_pool = mp_pool_new(sizeof(dlink_node), MP_CHUNK_SIZE_DNODE);
}
/* make_dlink_node()
@@ -50,9 +50,10 @@ init_dlink_nodes(void)
dlink_node *
make_dlink_node(void)
{
- dlink_node *lp = BlockHeapAlloc(dnode_heap);
+ dlink_node *ptr = mp_pool_get(dnode_pool);
- return lp;
+ memset(ptr, 0, sizeof(*ptr));
+ return ptr;
}
/* free_dlink_node()
@@ -64,7 +65,7 @@ make_dlink_node(void)
void
free_dlink_node(dlink_node *ptr)
{
- BlockHeapFree(dnode_heap, ptr);
+ mp_pool_release(ptr);
}
/*
@@ -213,7 +214,7 @@ dlink_move_node(dlink_node *m, dlink_list *list_del, dlink_list *list_add)
m->next->prev = m->prev;
else
{
- assert(list->tail == m);
+ assert(list_del->tail == m);
list_del->tail = m->prev;
}
@@ -221,7 +222,7 @@ dlink_move_node(dlink_node *m, dlink_list *list_del, dlink_list *list_add)
m->prev->next = m->next;
else
{
- assert(list->head == m);
+ assert(list_del->head == m);
list_del->head = m->next;
}
diff --git a/src/s_auth.c b/src/s_auth.c
index c14cb22..3c4f2a7 100644
--- a/src/s_auth.c
+++ b/src/s_auth.c
@@ -39,7 +39,6 @@
#include "fdlist.h"
#include "s_auth.h"
#include "conf.h"
-#include "balloc.h"
#include "client.h"
#include "event.h"
#include "hook.h"
@@ -50,6 +49,7 @@
#include "s_bsd.h"
#include "log.h"
#include "send.h"
+#include "mempool.h"
static const char *HeaderMessages[] = {
@@ -76,7 +76,7 @@ enum {
#define sendheader(c, i) sendto_one((c), HeaderMessages[(i)], me.name)
-static BlockHeap *auth_heap = NULL;
+static mp_pool_t *auth_pool = NULL;
static dlink_list auth_doing_list = { NULL, NULL, 0 };
static EVH timeout_auth_queries_event;
@@ -94,7 +94,7 @@ struct Callback *auth_cb = NULL;
void
init_auth(void)
{
- auth_heap = BlockHeapCreate("auth", sizeof(struct AuthRequest), AUTH_HEAP_SIZE);
+ auth_pool = mp_pool_new(sizeof(struct AuthRequest), MP_CHUNK_SIZE_AUTH);
auth_cb = register_callback("start_auth", start_auth);
eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1);
}
@@ -105,8 +105,9 @@ init_auth(void)
static struct AuthRequest *
make_auth_request(struct Client *client)
{
- struct AuthRequest *request = BlockHeapAlloc(auth_heap);
+ struct AuthRequest *request = mp_pool_get(auth_pool);
+ memset(request, 0, sizeof(*request));
client->localClient->auth = request;
request->client = client;
request->timeout = CurrentTime + CONNECTTIMEOUT;
@@ -129,7 +130,7 @@ release_auth_client(struct AuthRequest *auth)
client->localClient->auth = NULL;
dlinkDelete(&auth->node, &auth_doing_list);
- BlockHeapFree(auth_heap, auth);
+ mp_pool_release(auth);
/*
* When a client has auth'ed, we want to start reading what it sends
@@ -594,5 +595,5 @@ delete_auth(struct AuthRequest *auth)
fd_close(&auth->fd);
dlinkDelete(&auth->node, &auth_doing_list);
- BlockHeapFree(auth_heap, auth);
+ mp_pool_release(auth);
}
diff --git a/src/watch.c b/src/watch.c
index ba7db13..a5196e6 100644
--- a/src/watch.c
+++ b/src/watch.c
@@ -27,7 +27,6 @@
#include "stdinc.h"
#include "list.h"
-#include "balloc.h"
#include "s_user.h"
#include "s_misc.h"
#include "client.h"
@@ -42,21 +41,21 @@
#include "supported.h"
#include "whowas.h"
#include "memory.h"
+#include "mempool.h"
#include "packet.h"
#include "watch.h"
-#define WATCH_HEAP_SIZE 32
static dlink_list watchTable[HASHSIZE];
-static BlockHeap *watch_heap = NULL;
+static mp_pool_t *watch_pool = NULL;
/*! \brief Initializes the watch table
*/
void
watch_init(void)
{
- watch_heap = BlockHeapCreate("watch", sizeof(struct Watch), WATCH_HEAP_SIZE);
+ watch_pool = mp_pool_new(sizeof(struct Watch), MP_CHUNK_SIZE_WATCH);
}
/*
@@ -146,7 +145,8 @@ watch_add_to_hash_table(const char *nick, struct Client *client_p)
/* If found NULL (no header for this nick), make one... */
if ((anptr = watch_find_hash(nick)) == NULL)
{
- anptr = BlockHeapAlloc(watch_heap);
+ anptr = mp_pool_get(watch_pool);
+ memset(anptr, 0, sizeof(*anptr));
anptr->lasttime = CurrentTime;
strlcpy(anptr->nick, nick, sizeof(anptr->nick));
@@ -193,7 +193,7 @@ watch_del_from_hash_table(const char *nick, struct Client *client_p)
{
assert(dlinkFind(&watchTable[strhash(nick)], anptr) != NULL);
dlinkDelete(&anptr->node, &watchTable[strhash(nick)]);
- BlockHeapFree(watch_heap, anptr);
+ mp_pool_release(anptr);
}
}
@@ -223,7 +223,7 @@ watch_del_watch_list(struct Client *client_p)
assert(dlinkFind(&watchTable[strhash(anptr->nick)], anptr) != NULL);
dlinkDelete(&anptr->node, &watchTable[strhash(anptr->nick)]);
- BlockHeapFree(watch_heap, anptr);
+ mp_pool_release(anptr);
}
dlinkDelete(ptr, &client_p->localClient->watches);