X-Git-Url: https://jfr.im/git/irc/quakenet/snircd.git/blobdiff_plain/052b069e1613393c208fa736c856d62601dc6f99..9f8856e99d8fe297de1ddf0cff73dc2ff4900c60:/ircd/whowas.c diff --git a/ircd/whowas.c b/ircd/whowas.c index a5abe37..b3d8eca 100644 --- a/ircd/whowas.c +++ b/ircd/whowas.c @@ -69,7 +69,7 @@ struct Whowas* whowashash[WW_MAX]; /** @file * @brief Manipulation functions for the whowas list. - * @version $Id: whowas.c,v 1.17 2005/03/20 16:06:30 entrope Exp $ + * @version $Id: whowas.c,v 1.17.2.1 2006/03/25 03:46:56 entrope Exp $ * * Since the introduction of numeric nicks (at least for upstream messages, * like MODE +o <nick>, KICK #chan <nick>, KILL <nick> etc), there is no @@ -209,18 +209,6 @@ whowas_free(struct Whowas *ww) wwList.ww_alloc--; } -/** Initialize a whowas record. - * @param[in,out] ww Whowas record to initialize. - * @return The pointer \a ww. - */ -static struct Whowas * -whowas_init(struct Whowas *ww) -{ - if (ww) - memset(ww, 0, sizeof(*ww)); - return ww; -} - /** Return a fresh Whowas record. * If the total number of records is smaller than determined by * FEAT_NICKNAMEHISTORYLENGTH, allocate a new one. Otherwise, @@ -230,11 +218,20 @@ whowas_init(struct Whowas *ww) static struct Whowas * whowas_alloc(void) { - if (wwList.ww_alloc >= feature_int(FEAT_NICKNAMEHISTORYLENGTH)) - return whowas_init(whowas_clean(wwList.ww_tail)); + struct Whowas *ww; - wwList.ww_alloc++; /* going to allocate a new one... */ - return whowas_init((struct Whowas *) MyMalloc(sizeof(struct Whowas))); + if (wwList.ww_alloc >= feature_int(FEAT_NICKNAMEHISTORYLENGTH)) { + /* reclaim the oldest whowas entry */ + ww = whowas_clean(wwList.ww_tail); + } else { + /* allocate a new one */ + wwList.ww_alloc++; + ww = (struct Whowas *) MyMalloc(sizeof(struct Whowas)); + } + + assert(ww != NULL); + memset(ww, 0, sizeof(*ww)); + return ww; } /** If necessary, trim the whowas list.