mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Properly dispose the GSList chains
We forgot to free the link and the data, oops.
This commit is contained in:
parent
f4d811ddf5
commit
cfc8c9f8e2
@ -218,6 +218,19 @@ GSList *gslist_remove_string (GSList *list, const char *str)
|
||||
return list;
|
||||
}
|
||||
|
||||
GSList *gslist_delete_string (GSList *list, const char *str, GDestroyNotify free_func)
|
||||
{
|
||||
GSList *l;
|
||||
|
||||
l = g_slist_find_custom(list, str, (GCompareFunc) g_strcmp0);
|
||||
if (l != NULL) {
|
||||
free_func(l->data);
|
||||
return g_slist_delete_link(list, l);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/* `list' contains pointer to structure with a char* to string. */
|
||||
char *gslistptr_to_string(GSList *list, int offset, const char *delimiter)
|
||||
{
|
||||
|
@ -22,6 +22,7 @@ GSList *gslist_find_icase_string(GSList *list, const char *key);
|
||||
GList *glist_find_string(GList *list, const char *key);
|
||||
GList *glist_find_icase_string(GList *list, const char *key);
|
||||
GSList *gslist_remove_string (GSList *list, const char *str);
|
||||
GSList *gslist_delete_string (GSList *list, const char *str, GDestroyNotify free_func);
|
||||
|
||||
void gslist_free_full (GSList *list, GDestroyNotify free_func);
|
||||
|
||||
|
@ -36,7 +36,7 @@ int cap_toggle (IRC_SERVER_REC *server, char *cap, int enable)
|
||||
return TRUE;
|
||||
}
|
||||
else if (!enable && gslist_find_string(server->cap_queue, cap)) {
|
||||
server->cap_queue = gslist_remove_string(server->cap_queue, cap);
|
||||
server->cap_queue = gslist_delete_string(server->cap_queue, cap, g_free);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -135,8 +135,6 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
|
||||
return;
|
||||
}
|
||||
|
||||
g_warning("%s -> %s", evt, list);
|
||||
|
||||
/* Strip the trailing whitespaces before splitting the string, some servers send responses with
|
||||
* superfluous whitespaces that g_strsplit the interprets as tokens */
|
||||
caps = g_strsplit(g_strchomp(list), " ", -1);
|
||||
@ -214,7 +212,7 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
|
||||
disable = (*caps[i] == '-');
|
||||
|
||||
if (disable)
|
||||
server->cap_active = gslist_remove_string(server->cap_active, caps[i] + 1);
|
||||
server->cap_active = gslist_delete_string(server->cap_active, caps[i] + 1, g_free);
|
||||
else
|
||||
server->cap_active = g_slist_prepend(server->cap_active, g_strdup(caps[i]));
|
||||
|
||||
@ -265,7 +263,7 @@ static void event_cap (IRC_SERVER_REC *server, char *args, char *nick, char *add
|
||||
cap_emit_signal(server, "delete", key);
|
||||
/* The server removed this CAP, remove it from the list
|
||||
* of the active ones if we had requested it */
|
||||
server->cap_active = gslist_remove_string(server->cap_active, key);
|
||||
server->cap_active = gslist_delete_string(server->cap_active, key, g_free);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user