added .gitignore
[NeonServV5.git] / UserNode.c
index 465fd2e04bf6d2c43a221cebe6ab25c9d58ffbed..3b18cbd0e1c55d7ef254790b2576ce3a4257d166 100644 (file)
@@ -7,6 +7,20 @@ void init_UserNode() {
     userList = calloc(VALID_NICK_CHARS_FIRST_LEN+1, sizeof(*userList));
 }
 
+void free_UserNode() {
+    //kamikaze free all users
+    //chanusers will be destroyed in free_ChanNode()
+    int i;
+    struct UserNode *user, *next;
+    for(i = 0; i < VALID_NICK_CHARS_FIRST_LEN+1; i++) {
+        for(user = userList[i]; user; user = next) {
+            next = user->next;
+            free(user);
+        }
+    }
+    free(userList);
+}
+
 int is_valid_nick(const char *nick) {
     unsigned int i;
     //first char must be one of: a-zA-Z{|}~[\]^_`