--- a/libpurple/account.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/account.c Fri Feb 26 00:17:26 2021 -0600
@@ -2791,13 +2791,10 @@
protocol = purple_connection_get_protocol(gc);
- GList *cur, *groups = NULL;
/* Make a list of what group each buddy is in */
- for (cur = buddies; cur != NULL; cur = cur->next) {
- PurpleBuddy *buddy = cur->data;
- groups = g_list_append(groups, purple_buddy_get_group(buddy));
+ groups = g_list_copy_deep(buddies, (GCopyFunc)purple_buddy_get_group, NULL); if(PURPLE_IS_PROTOCOL_SERVER(protocol)) {
purple_protocol_server_add_buddies(PURPLE_PROTOCOL_SERVER(protocol),
--- a/libpurple/media/backend-fs2.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/media/backend-fs2.c Fri Feb 26 00:17:26 2021 -0600
@@ -634,20 +634,6 @@
-candidate_list_to_fs(GList *candidates)
- GList *new_list = NULL;
- for (; candidates; candidates = g_list_next(candidates)) {
- new_list = g_list_prepend(new_list,
- candidate_to_fs(candidates->data));
- new_list = g_list_reverse(new_list);
static PurpleMediaCandidate *
candidate_from_fs(FsCandidate *fscandidate)
@@ -671,20 +657,6 @@
-candidate_list_from_fs(GList *candidates)
- GList *new_list = NULL;
- for (; candidates; candidates = g_list_next(candidates)) {
- new_list = g_list_prepend(new_list,
- candidate_from_fs(candidates->data));
- new_list = g_list_reverse(new_list);
codec_to_fs(const PurpleMediaCodec *codec)
@@ -746,34 +718,6 @@
-codec_list_from_fs(GList *codecs)
- GList *new_list = NULL;
- for (; codecs; codecs = g_list_next(codecs)) {
- new_list = g_list_prepend(new_list,
- codec_from_fs(codecs->data));
- new_list = g_list_reverse(new_list);
-codec_list_to_fs(GList *codecs)
- GList *new_list = NULL;
- for (; codecs; codecs = g_list_next(codecs)) {
- new_list = g_list_prepend(new_list,
- codec_to_fs(codecs->data));
- new_list = g_list_reverse(new_list);
static PurpleMediaBackendFs2Session *
get_session(PurpleMediaBackendFs2 *self, const gchar *sess_id)
@@ -2167,7 +2111,7 @@
stream->remote_candidates = g_list_concat(stream->remote_candidates,
- candidate_list_to_fs(remote_candidates));
+ g_list_copy_deep(remote_candidates, (GCopyFunc)candidate_to_fs, NULL)); if (purple_media_is_initiator(priv->media, sess_id, participant) ||
@@ -2274,7 +2218,7 @@
g_object_get(G_OBJECT(session->session),
"codecs", &fscodecs, NULL);
- codecs = codec_list_from_fs(fscodecs);
+ codecs = g_list_copy_deep(fscodecs, (GCopyFunc)codec_from_fs, NULL); fs_codec_list_destroy(fscodecs);
@@ -2292,9 +2236,10 @@
stream = get_stream(PURPLE_MEDIA_BACKEND_FS2(self),
- candidates = candidate_list_from_fs(
- stream->local_candidates);
+ candidates = g_list_copy_deep(stream->local_candidates, + (GCopyFunc)candidate_from_fs, NULL); @@ -2314,7 +2259,7 @@
- fscodecs = codec_list_to_fs(codecs);
+ fscodecs = g_list_copy_deep(codecs, (GCopyFunc)codec_to_fs, NULL); fs_stream_set_remote_codecs(stream->stream, fscodecs, &err);
fs_codec_list_destroy(fscodecs);
--- a/libpurple/media/candidate.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/media/candidate.c Fri Feb 26 00:17:26 2021 -0600
@@ -352,15 +352,7 @@
purple_media_candidate_list_copy(GList *candidates)
- GList *new_list = NULL;
- for (; candidates; candidates = g_list_next(candidates)) {
- new_list = g_list_prepend(new_list,
- purple_media_candidate_copy(candidates->data));
- new_list = g_list_reverse(new_list);
+ return g_list_copy_deep(candidates, (GCopyFunc)purple_media_candidate_copy, NULL); --- a/libpurple/media/codec.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/media/codec.c Fri Feb 26 00:17:26 2021 -0600
@@ -343,15 +343,7 @@
purple_media_codec_list_copy(GList *codecs)
- GList *new_list = NULL;
- for (; codecs; codecs = g_list_next(codecs)) {
- new_list = g_list_prepend(new_list,
- purple_media_codec_copy(codecs->data));
- new_list = g_list_reverse(new_list);
+ return g_list_copy_deep(codecs, (GCopyFunc)purple_media_codec_copy, NULL); --- a/libpurple/prefs.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/prefs.c Fri Feb 26 00:17:26 2021 -0600
@@ -739,7 +739,6 @@
purple_prefs_add_path_list(const char *name, GList *value)
struct purple_pref *pref;
/* re-use the string list UI OP */
PURPLE_PREFS_UI_OP_CALL(add_string_list, name, value);
@@ -749,9 +748,8 @@
- for(tmp = value; tmp; tmp = tmp->next)
- pref->value.stringlist = g_list_append(pref->value.stringlist,
+ pref->value.stringlist = g_list_concat(pref->value.stringlist, + g_list_copy_deep(value, (GCopyFunc)g_strdup, NULL)); @@ -1065,8 +1063,6 @@
if(pref->type != PURPLE_PREF_PATH_LIST) {
purple_debug_error("prefs",
"purple_prefs_set_path_list: %s not a path list pref\n",
@@ -1075,12 +1071,7 @@
g_list_free_full(pref->value.stringlist, g_free);
- pref->value.stringlist = NULL;
- for(tmp = value; tmp; tmp = tmp->next)
- pref->value.stringlist = g_list_prepend(pref->value.stringlist,
- pref->value.stringlist = g_list_reverse(pref->value.stringlist);
+ pref->value.stringlist = g_list_copy_deep(value, (GCopyFunc)g_strdup, NULL); do_callbacks(name, pref);
@@ -1190,7 +1181,6 @@
purple_prefs_get_string_list(const char *name)
struct purple_pref *pref;
- GList *ret = NULL, *tmp;
PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name);
@@ -1206,11 +1196,7 @@
- for(tmp = pref->value.stringlist; tmp; tmp = tmp->next)
- ret = g_list_prepend(ret, g_strdup(tmp->data));
- ret = g_list_reverse(ret);
+ return g_list_copy_deep(pref->value.stringlist, (GCopyFunc)g_strdup, NULL); @@ -1239,7 +1225,6 @@
purple_prefs_get_path_list(const char *name)
struct purple_pref *pref;
- GList *ret = NULL, *tmp;
PURPLE_PREFS_UI_OP_CALL_RETURN(get_string_list, name);
@@ -1255,11 +1240,7 @@
- for(tmp = pref->value.stringlist; tmp; tmp = tmp->next)
- ret = g_list_prepend(ret, g_strdup(tmp->data));
- ret = g_list_reverse(ret);
+ return g_list_copy_deep(pref->value.stringlist, (GCopyFunc)g_strdup, NULL); --- a/libpurple/protocols.c Fri Feb 26 00:12:08 2021 -0600
+++ b/libpurple/protocols.c Fri Feb 26 00:17:26 2021 -0600
@@ -340,22 +340,11 @@
purple_protocol_get_statuses(PurpleAccount *account, PurplePresence *presence)
- GList *statuses = NULL;
g_return_val_if_fail(account != NULL, NULL);
g_return_val_if_fail(presence != NULL, NULL);
- for (l = purple_account_get_status_types(account); l != NULL; l = l->next)
- status = purple_status_new((PurpleStatusType *)l->data, presence);
- statuses = g_list_prepend(statuses, status);
- statuses = g_list_reverse(statuses);
+ return g_list_copy_deep(purple_account_get_status_types(account), + (GCopyFunc)purple_status_new, presence);