#include "../core/error.h"
#include "../lib/sstring.h"
-#define hosthash(x) ((crc32i(x))%HOSTHASHSIZE)
-#define realnamehash(x) ((crc32(x))%REALNAMEHASHSIZE)
+#include <string.h>
-unsigned int hostmarker;
-unsigned int realnamemarker;
-unsigned int nickmarker;
+#define hosthash(x) ((irc_crc32i(x))%HOSTHASHSIZE)
+#define realnamehash(x) ((irc_crc32(x))%REALNAMEHASHSIZE)
host *hosttable[HOSTHASHSIZE];
realname *realnametable[REALNAMEHASHSIZE];
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) {
unsigned int nexthostmarker() {
int i;
host *hp;
+ static unsigned int hostmarker=0;
hostmarker++;
if (!hostmarker) {
unsigned int nextrealnamemarker() {
int i;
realname *rnp;
+ static unsigned int realnamemarker=0;
realnamemarker++;
if (!realnamemarker) {
unsigned int nextnickmarker() {
int i;
nick *np;
+ static unsigned int nickmarker=0;
nickmarker++;