summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/misc.c13
-rw-r--r--src/core/misc.h1
-rw-r--r--src/irc/core/irc-cap.c8
3 files changed, 17 insertions, 5 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 4e9f4bbe..27741220 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -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)
{
diff --git a/src/core/misc.h b/src/core/misc.h
index 375744db..689cf5c2 100644
--- a/src/core/misc.h
+++ b/src/core/misc.h
@@ -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);
diff --git a/src/irc/core/irc-cap.c b/src/irc/core/irc-cap.c
index 2378d640..a5ae07aa 100644
--- a/src/irc/core/irc-cap.c
+++ b/src/irc/core/irc-cap.c
@@ -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 {