From 6dd916eaedfd23a93ba7aa2e2b39511e7e907dec Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 26 Mar 2010 14:06:52 +0100 Subject: Fixed memory leaks in hash tables and nick list. --- channel.c | 2 ++ nick.c | 2 +- user.c | 2 ++ word.c | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/channel.c b/channel.c index 86e993d..8c32a96 100644 --- a/channel.c +++ b/channel.c @@ -55,9 +55,11 @@ struct channel_t *channel_get(int index) { void channel_free() { for(int i = 0; i < channel_count; i++) { free(channels[i].name); + free(channels[i].xmlpath); struct channel_file_t *file = channels[i].files; while(file) { struct channel_file_t *next = file->next; + free(file->path); free(file); file = next; } diff --git a/nick.c b/nick.c index 181a3a1..088edca 100644 --- a/nick.c +++ b/nick.c @@ -103,6 +103,6 @@ void nick_free() { free(nick); nick = next; } - free(nicks); + nicks = NULL; // nicks already free'd by first iteration pcre_free((void*)nick_pcre_tables); } diff --git a/user.c b/user.c index de10e1c..b64ca7c 100644 --- a/user.c +++ b/user.c @@ -44,6 +44,8 @@ struct user_t *user_get(char *nick) { void user_free() { struct user_t *user; for(int i = 0; i < USERS_MAX; i++) { + if(users[i].nick) + free(users[i].nick); user = users[i].next; while(user) { struct user_t *temp = user->next; diff --git a/word.c b/word.c index bf1fada..1e8d56a 100644 --- a/word.c +++ b/word.c @@ -37,6 +37,8 @@ struct word_t *word_get(char *name) { void word_free() { struct word_t *word; for(int i = 0; i < WORDS_MAX; i++) { + if(words[i].name) + free(words[i].name); word = words[i].next; while(word) { struct word_t *temp = word->next; -- cgit v1.2.3