]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/hash.c
Some global structs cleaned up a bit in their initalization and declarations.
[irc/rqf/shadowircd.git] / src / hash.c
index 9c0e7ec41edf9d105c643617fb18f6f953ee8011..561c7dc9b7aa1fde8d0de52b2fef161e7ac9e145 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "stdinc.h"
 #include "ircd_defs.h"
-#include "tools.h"
 #include "s_conf.h"
 #include "channel.h"
 #include "client.h"
@@ -36,7 +35,6 @@
 #include "ircd.h"
 #include "numeric.h"
 #include "send.h"
-#include "memory.h"
 #include "msg.h"
 #include "cache.h"
 #include "s_newconf.h"
@@ -91,11 +89,11 @@ rb_dlink_list *hostTable;
 void
 init_hash(void)
 {
-       clientTable = MyMalloc(sizeof(rb_dlink_list) * U_MAX);
-       idTable = MyMalloc(sizeof(rb_dlink_list) * U_MAX);
-       channelTable = MyMalloc(sizeof(rb_dlink_list) * CH_MAX);
-       hostTable = MyMalloc(sizeof(rb_dlink_list) * HOST_MAX);
-       resvTable = MyMalloc(sizeof(rb_dlink_list) * R_MAX);
+       clientTable = rb_malloc(sizeof(rb_dlink_list) * U_MAX);
+       idTable = rb_malloc(sizeof(rb_dlink_list) * U_MAX);
+       channelTable = rb_malloc(sizeof(rb_dlink_list) * CH_MAX);
+       hostTable = rb_malloc(sizeof(rb_dlink_list) * HOST_MAX);
+       resvTable = rb_malloc(sizeof(rb_dlink_list) * R_MAX);
 }
 
 #ifndef RICER_HASHING
@@ -389,7 +387,7 @@ find_id(const char *name)
 
        hashv = hash_id(name);
 
-       DLINK_FOREACH(ptr, idTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, idTable[hashv].head)
        {
                target_p = ptr->data;
 
@@ -421,7 +419,7 @@ find_client(const char *name)
 
        hashv = hash_nick(name);
 
-       DLINK_FOREACH(ptr, clientTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, clientTable[hashv].head)
        {
                target_p = ptr->data;
 
@@ -449,7 +447,7 @@ find_named_client(const char *name)
 
        hashv = hash_nick(name);
 
-       DLINK_FOREACH(ptr, clientTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, clientTable[hashv].head)
        {
                target_p = ptr->data;
 
@@ -483,7 +481,7 @@ find_server(struct Client *source_p, const char *name)
 
        hashv = hash_nick(name);
 
-       DLINK_FOREACH(ptr, clientTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, clientTable[hashv].head)
        {
                target_p = ptr->data;
 
@@ -531,7 +529,7 @@ find_channel(const char *name)
 
        hashv = hash_channel(name);
 
-       DLINK_FOREACH(ptr, channelTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, channelTable[hashv].head)
        {
                chptr = ptr->data;
 
@@ -583,7 +581,7 @@ get_or_create_channel(struct Client *client_p, const char *chname, int *isnew)
 
        hashv = hash_channel(s);
 
-       DLINK_FOREACH(ptr, channelTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, channelTable[hashv].head)
        {
                chptr = ptr->data;
 
@@ -602,7 +600,7 @@ get_or_create_channel(struct Client *client_p, const char *chname, int *isnew)
 
        rb_dlinkAdd(chptr, &chptr->node, &global_channel_list);
 
-       chptr->channelts = CurrentTime; /* doesn't hurt to set it here */
+       chptr->channelts = rb_current_time();   /* doesn't hurt to set it here */
 
        rb_dlinkAddAlloc(chptr, &channelTable[hashv]);
 
@@ -626,7 +624,7 @@ hash_find_resv(const char *name)
 
        hashv = hash_resv(name);
 
-       DLINK_FOREACH(ptr, resvTable[hashv].head)
+       RB_DLINK_FOREACH(ptr, resvTable[hashv].head)
        {
                aconf = ptr->data;
 
@@ -667,14 +665,16 @@ output_hash(struct Client *source_p, const char *name, int length, int *counts,
 {
        unsigned long total = 0;
        int i;
+       char buf[128];
 
        sendto_one_numeric(source_p, RPL_STATSDEBUG,
                        "B :%s Hash Statistics", name);
 
-       sendto_one_numeric(source_p, RPL_STATSDEBUG,
-                       "B :Size: %d Empty: %d (%.3f%%)",
-                       length, counts[0], 
+       snprintf(buf, sizeof buf, "%.3f%%",
                        (float) ((counts[0]*100) / (float) length));
+       sendto_one_numeric(source_p, RPL_STATSDEBUG,
+                       "B :Size: %d Empty: %d (%s)",
+                       length, counts[0], buf);
 
        for(i = 1; i < 11; i++)
        {
@@ -683,10 +683,14 @@ output_hash(struct Client *source_p, const char *name, int length, int *counts,
 
        /* dont want to divide by 0! --fl */
        if(counts[0] != length)
-               sendto_one_numeric(source_p, RPL_STATSDEBUG,
-                               "B :Average depth: %.3f/%.3f Highest depth: %d",
+       {
+               snprintf(buf, sizeof buf, "%.3f/%.3f",
                                (float) (total / (length - counts[0])),
-                               (float) (total / length), deepest);
+                               (float) (total / length));
+               sendto_one_numeric(source_p, RPL_STATSDEBUG,
+                               "B :Average depth: %s Highest depth: %d",
+                               buf, deepest);
+       }
 
        for(i = 0; i < 11; i++)
        {