From 9acb4d06a759c067c846b8fd29f825556667dbf9 Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 15 Apr 2013 09:09:09 +0000 Subject: - Minor cleanups to hash.c; removed now unused functions, style cleanups git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1826 82007160-df01-0410-b94d-b575c5fd34c7 --- include/hash.h | 7 +---- modules/m_hash.c | 24 ----------------- src/channel.c | 3 ++- src/hash.c | 82 +++----------------------------------------------------- 4 files changed, 7 insertions(+), 109 deletions(-) diff --git a/include/hash.h b/include/hash.h index bb4bb06..9398bbc 100644 --- a/include/hash.h +++ b/include/hash.h @@ -32,7 +32,6 @@ struct Client; struct Channel; -struct MaskItem; struct UserHost; enum @@ -40,8 +39,7 @@ enum HASH_TYPE_ID, HASH_TYPE_CLIENT, HASH_TYPE_CHANNEL, - HASH_TYPE_USERHOST, - HASH_TYPE_RESERVED + HASH_TYPE_USERHOST }; extern void hash_init(void); @@ -49,8 +47,6 @@ extern void hash_add_client(struct Client *); extern void hash_del_client(struct Client *); extern void hash_add_channel(struct Channel *); extern void hash_del_channel(struct Channel *); -extern void hash_add_resv(struct MaskItem *); -extern void hash_del_resv(struct MaskItem *); extern void hash_add_id(struct Client *); extern void hash_del_id(struct Client *); extern void hash_add_userhost(struct UserHost *); @@ -62,7 +58,6 @@ extern struct Client *hash_find_client(const char *); extern struct Client *hash_find_server(const char *); extern struct Channel *hash_find_channel(const char *); extern void *hash_get_bucket(int, unsigned int); -extern struct MaskItem *hash_find_resv(const char *); extern void free_list_task(struct ListTask *, struct Client *); extern void safe_list_channels(struct Client *, struct ListTask *, int); diff --git a/modules/m_hash.c b/modules/m_hash.c index ddf7d51..1c1b4a8 100644 --- a/modules/m_hash.c +++ b/modules/m_hash.c @@ -48,7 +48,6 @@ mo_hash(struct Client *client_p, struct Client *source_p, struct Client *icl; struct Channel *ch; struct UserHost *ush; - struct MaskItem *rch; for (i = 0; i < HASHSIZE; ++i) { @@ -96,29 +95,6 @@ mo_hash(struct Client *client_p, struct Client *source_p, buckets = 0; max_chain = 0; - for (i = 0; i < HASHSIZE; ++i) - { - if ((rch = hash_get_bucket(HASH_TYPE_RESERVED, i)) != NULL) - { - int len = 0; - - ++buckets; - for (; rch != NULL; rch = rch->hnext) - ++len; - if (len > max_chain) - max_chain = len; - count += len; - } - } - - sendto_one(source_p, ":%s NOTICE %s :Resv: entries: %d buckets: %d " - "max chain: %d", me.name, source_p->name, count, buckets, - max_chain); - - count = 0; - buckets = 0; - max_chain = 0; - for (i = 0; i < HASHSIZE; ++i) { if ((icl = hash_get_bucket(HASH_TYPE_ID, i)) != NULL) diff --git a/src/channel.c b/src/channel.c index 5ee5977..ac31a36 100644 --- a/src/channel.c +++ b/src/channel.c @@ -42,6 +42,7 @@ #include "memory.h" #include "mempool.h" #include "s_misc.h" +#include "resv.h" struct config_channel_entry ConfigChannel; dlink_list global_channel_list = { NULL, NULL, 0 }; @@ -718,7 +719,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct Membership *ms) if (MyClient(source_p) && !IsExemptResv(source_p)) if (!(HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.oper_pass_resv)) - if (!hash_find_resv(chptr->chname) == ConfigChannel.restrict_channels) + if (!match_find_resv(chptr->chname) == ConfigChannel.restrict_channels) return ERR_CANNOTSENDTOCHAN; if (ms != NULL || (ms = find_channel_link(source_p, chptr))) diff --git a/src/hash.c b/src/hash.c index 085338d..4dad3c7 100644 --- a/src/hash.c +++ b/src/hash.c @@ -57,7 +57,6 @@ static struct Client *idTable[HASHSIZE]; static struct Client *clientTable[HASHSIZE]; static struct Channel *channelTable[HASHSIZE]; static struct UserHost *userhostTable[HASHSIZE]; -static struct MaskItem *resvchannelTable[HASHSIZE]; /* init_hash() @@ -93,7 +92,7 @@ strhash(const char *name) const unsigned char *p = (const unsigned char *)name; unsigned int hval = FNV1_32_INIT; - if (*p == '\0') + if (EmptyString(p)) return 0; for (; *p != '\0'; ++p) { @@ -152,15 +151,6 @@ hash_add_channel(struct Channel *chptr) channelTable[hashv] = chptr; } -void -hash_add_resv(struct MaskItem *conf) -{ - unsigned int hashv = strhash(conf->name); - - conf->hnext = resvchannelTable[hashv]; - resvchannelTable[hashv] = conf; -} - void hash_add_userhost(struct UserHost *userhost) { @@ -304,31 +294,6 @@ hash_del_channel(struct Channel *chptr) } } -void -hash_del_resv(struct MaskItem *chptr) -{ - unsigned int hashv = strhash(chptr->name); - struct MaskItem *tmp = resvchannelTable[hashv]; - - if (tmp != NULL) - { - if (tmp == chptr) - { - resvchannelTable[hashv] = chptr->hnext; - chptr->hnext = chptr; - } - else - { - while (tmp->hnext != chptr) - if ((tmp = tmp->hnext) == NULL) - return; - - tmp->hnext = tmp->hnext->hnext; - chptr->hnext = chptr; - } - } -} - /* hash_find_client() * * inputs - pointer to name @@ -493,9 +458,6 @@ hash_get_bucket(int type, unsigned int hashv) case HASH_TYPE_USERHOST: return userhostTable[hashv]; break; - case HASH_TYPE_RESERVED: - return resvchannelTable[hashv]; - break; default: assert(0); } @@ -503,42 +465,6 @@ hash_get_bucket(int type, unsigned int hashv) return NULL; } -/* hash_find_resv() - * - * inputs - pointer to name - * output - NONE - * side effects - New semantics: finds a reserved channel whose name is 'name', - * if can't find one returns NULL, if can find it moves - * it to the top of the list and returns it. - */ -struct MaskItem * -hash_find_resv(const char *name) -{ - unsigned int hashv = strhash(name); - struct MaskItem *chptr; - - if ((chptr = resvchannelTable[hashv]) != NULL) - { - if (irccmp(name, chptr->name)) - { - struct MaskItem *prev; - - while (prev = chptr, (chptr = chptr->hnext) != NULL) - { - if (!irccmp(name, chptr->name)) - { - prev->hnext = chptr->hnext; - chptr->hnext = resvchannelTable[hashv]; - resvchannelTable[hashv] = chptr; - break; - } - } - } - } - - return chptr; -} - struct UserHost * hash_find_userhost(const char *host) { @@ -781,7 +707,7 @@ exceeding_sendq(struct Client *to) void free_list_task(struct ListTask *lt, struct Client *source_p) { - dlink_node *dl, *dln; + dlink_node *dl = NULL, *dln = NULL; if ((dl = dlinkFindDelete(&listing_client_list, source_p)) != NULL) free_dlink_node(dl); @@ -813,9 +739,9 @@ free_list_task(struct ListTask *lt, struct Client *source_p) * side effects - */ static int -list_allow_channel(const char *chname, struct ListTask *lt) +list_allow_channel(const char *chname, const struct ListTask *lt) { - dlink_node *dl = NULL; + const dlink_node *dl = NULL; DLINK_FOREACH(dl, lt->show_mask.head) if (match(dl->data, chname) != 0) -- cgit