]> jfr.im git - irc/quakenet/newserv.git/blobdiff - nick/nickhelpers.c
TRUSTS: require sqlite
[irc/quakenet/newserv.git] / nick / nickhelpers.c
index ac660002a82add35e9b700e6923940a6821c14bb..6cf065dd071b7191632b065da9d9ad651690ba95 100644 (file)
@@ -9,8 +9,8 @@
 
 #include <string.h>
 
-#define hosthash(x)       ((crc32i(x))%HOSTHASHSIZE)
-#define realnamehash(x)   ((crc32(x))%REALNAMEHASHSIZE)
+#define hosthash(x)       ((irc_crc32i(x))%HOSTHASHSIZE)
+#define realnamehash(x)   ((irc_crc32(x))%REALNAMEHASHSIZE)
 
 host *hosttable[HOSTHASHSIZE];
 realname *realnametable[REALNAMEHASHSIZE];
@@ -20,6 +20,30 @@ void initnickhelpers() {
   memset(realnametable,0,sizeof(realnametable));
 }
 
+void fininickhelpers() {
+  host *hnp, *hnpn;
+  realname *rnp, *rnpn;
+  int i;
+
+  for(i=0;i<HOSTHASHSIZE;i++) {
+    for(hnp=hosttable[i];hnp;hnp=hnpn) {
+      hnpn=hnp->next;
+      freesstring(hnp->name);
+      freehost(hnp);
+    }
+    hosttable[i]=NULL;
+  }
+
+  for(i=0;i<REALNAMEHASHSIZE;i++) {
+    for(rnp=realnametable[i];rnp;rnp=rnpn) {
+      rnpn=rnp->next;
+      freesstring(rnp->name);
+      freerealname(rnp);
+    }
+    realnametable[i]=NULL;
+  }
+}
+
 host *findhost(const char *hostname) {
   host *hp;
   for (hp=hosttable[hosthash(hostname)];hp;hp=(host *)hp->next) {