summaryrefslogtreecommitdiff
path: root/xchat
diff options
context:
space:
mode:
authorStefano Candori <stefano.candori@gmail.com>2011-01-17 14:33:00 +0100
committerStefano Candori <stefano.candori@gmail.com>2011-01-17 14:33:00 +0100
commit2b77a1fe7c578ad39254c8533850a52a47abe4da (patch)
tree181f092d42c7f449ca553ff184e14a6c5c06341f /xchat
parentd140e8116786ca13fe0962e895c2d81b839da89f (diff)
Fixed memory leaks
Diffstat (limited to 'xchat')
-rw-r--r--xchat/zeitgeist-dataprovider.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/xchat/zeitgeist-dataprovider.c b/xchat/zeitgeist-dataprovider.c
index 1f029ec..9280d41 100644
--- a/xchat/zeitgeist-dataprovider.c
+++ b/xchat/zeitgeist-dataprovider.c
@@ -81,6 +81,9 @@ static int join_cb(char *word[], void *userdata)
send_event_to_zeitgeist(url, text, ZEITGEIST_ZG_ACCESS_EVENT);
+ g_free(url);
+ g_free(text);
+
return XCHAT_EAT_NONE;
}
@@ -89,13 +92,29 @@ static int part_cb(char *word[], char* word_eol[], void *userdata)
const char *server = xchat_get_info(ph, "host");
const char *channel = word[3];
char *url, *text;
-
- channel_list = g_slist_remove(channel_list, g_strdup(channel));
-
+ gpointer data = NULL;
+ GSList *tmp = channel_list;
+
url = g_strconcat("irc://", server, "/", channel, NULL);
text = g_strconcat("You parted from ", channel, NULL);
send_event_to_zeitgeist(url, text, ZEITGEIST_ZG_LEAVE_EVENT);
+
+ while(tmp)
+ {
+ if (g_strcmp0 (tmp->data, channel) == 0)
+ {
+ data = tmp->data;
+ channel_list = g_slist_remove(channel_list, data);
+ g_free(data);
+ data = NULL;
+ break;
+ }
+ tmp = tmp->next;
+ }
+
+ g_free(url);
+ g_free(text);
return XCHAT_EAT_NONE;
}
@@ -111,6 +130,9 @@ static int message_cb(char *word[], void *userdata)
send_event_to_zeitgeist(url, text, ZEITGEIST_ZG_SEND_EVENT);
+ g_free(url);
+ g_free(text);
+
return XCHAT_EAT_NONE;
}
@@ -124,24 +146,26 @@ static int priv_message_cb(char *word[], void *userdata)
text = g_strconcat(channel, ": you received \"", word[2],"\" from ", word[1], NULL);
send_event_to_zeitgeist(url, text, ZEITGEIST_ZG_RECEIVE_EVENT);
-
+
+ g_free(url);
+ g_free(text);
+
return XCHAT_EAT_NONE;
}
static void on_quit(gpointer data, gpointer userdata)
{
const char *server = xchat_get_info(ph, "host");
- char *channel = g_strdup((char*) data);
- char *url, *text;
-
- channel_list = g_slist_remove(channel_list, channel);
+ const char *channel = (const char*) data;
+ char *url, *text;
url = g_strconcat("irc://", server, "/", channel, NULL);
text = g_strconcat("You parted from ", channel, NULL);
send_event_to_zeitgeist(url, text, ZEITGEIST_ZG_LEAVE_EVENT);
- g_free(channel);
+ g_free(url);
+ g_free(text);
}
void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved)
@@ -197,7 +221,7 @@ int xchat_plugin_deinit()
}
g_slist_foreach(channel_list, on_quit, NULL);
-
+ g_slist_foreach(channel_list, (GFunc)g_free, NULL);
g_slist_free(channel_list);
channel_list = NULL;