Sun, 13 Mar 2022 21:59:39 -0500
Remove deep parameter from dup functions
All callers all require deep copies now.
--- a/libpurple/protocols/facebook/api.c Sun Mar 13 21:59:38 2022 -0500 +++ b/libpurple/protocols/facebook/api.c Sun Mar 13 21:59:39 2022 -0500 @@ -3264,7 +3264,7 @@ } FbApiEvent * -fb_api_event_dup(const FbApiEvent *event, gboolean deep) +fb_api_event_dup(const FbApiEvent *event) { FbApiEvent *ret; @@ -3273,10 +3273,7 @@ } ret = g_memdup2(event, sizeof *event); - - if (deep) { - ret->text = g_strdup(event->text); - } + ret->text = g_strdup(event->text); return ret; } @@ -3303,7 +3300,7 @@ } FbApiMessage * -fb_api_message_dup(const FbApiMessage *msg, gboolean deep) +fb_api_message_dup(const FbApiMessage *msg) { FbApiMessage *ret; @@ -3312,10 +3309,7 @@ } ret = g_memdup2(msg, sizeof *msg); - - if (deep) { - ret->text = g_strdup(msg->text); - } + ret->text = g_strdup(msg->text); return ret; } @@ -3363,29 +3357,17 @@ } FbApiThread * -fb_api_thread_dup(const FbApiThread *thrd, gboolean deep) +fb_api_thread_dup(const FbApiThread *thrd) { FbApiThread *ret; - FbApiUser *user; - GSList *l; if (thrd == NULL) { return NULL; } ret = g_memdup2(thrd, sizeof *thrd); - - if (deep) { - ret->users = NULL; - - for (l = thrd->users; l != NULL; l = l->next) { - user = fb_api_user_dup(l->data, TRUE); - ret->users = g_slist_prepend(ret->users, user); - } - - ret->topic = g_strdup(thrd->topic); - ret->users = g_slist_reverse(ret->users); - } + ret->topic = g_strdup(thrd->topic); + ret->users = g_slist_copy_deep(thrd->users, (GCopyFunc)fb_api_user_dup, NULL); return ret; } @@ -3435,7 +3417,7 @@ } FbApiUser * -fb_api_user_dup(const FbApiUser *user, gboolean deep) +fb_api_user_dup(const FbApiUser *user) { FbApiUser *ret; @@ -3444,12 +3426,9 @@ } ret = g_memdup2(user, sizeof *user); - - if (deep) { - ret->name = g_strdup(user->name); - ret->icon = g_strdup(user->icon); - ret->csum = g_strdup(user->csum); - } + ret->name = g_strdup(user->name); + ret->icon = g_strdup(user->icon); + ret->csum = g_strdup(user->csum); return ret; }
--- a/libpurple/protocols/facebook/api.h Sun Mar 13 21:59:38 2022 -0500 +++ b/libpurple/protocols/facebook/api.h Sun Mar 13 21:59:39 2022 -0500 @@ -764,7 +764,6 @@ /** * fb_api_event_dup: * @event: The #FbApiEvent or #NULL. - * @deep: #TRUE to duplicate allocated data, otherwise #FALSE. * * Duplicates an #FbApiEvent. The returned #FbApiEvent should be freed with * #fb_api_event_free() when no longer needed. @@ -772,7 +771,7 @@ * Returns: The new #FbApiEvent. */ FbApiEvent * -fb_api_event_dup(const FbApiEvent *event, gboolean deep); +fb_api_event_dup(const FbApiEvent *event); /** * fb_api_event_reset: @@ -796,7 +795,6 @@ /** * fb_api_message_dup: * @msg: The #FbApiMessage or #NULL. - * @deep: #TRUE to duplicate allocated data, otherwise #FALSE. * * Duplicates an #FbApiMessage. The returned #FbApiMessage should be freed with * #fb_api_message_free() when no longer needed. @@ -804,7 +802,7 @@ * Returns: The new #FbApiMessage. */ FbApiMessage * -fb_api_message_dup(const FbApiMessage *msg, gboolean deep); +fb_api_message_dup(const FbApiMessage *msg); /** * fb_api_message_reset: @@ -858,7 +856,6 @@ /** * fb_api_thread_dup: * @thrd: The #FbApiThread or #NULL. - * @deep: #TRUE to duplicate allocated data, otherwise #FALSE. * * Duplicates an #FbApiThread. The returned #FbApiThread should be freed with * #fb_api_thread_free() when no longer needed. @@ -866,7 +863,7 @@ * Returns: The new #FbApiThread. */ FbApiThread * -fb_api_thread_dup(const FbApiThread *thrd, gboolean deep); +fb_api_thread_dup(const FbApiThread *thrd); /** * fb_api_thread_reset: @@ -920,7 +917,6 @@ /** * fb_api_user_dup: * @user: The #FbApiUser or #NULL. - * @deep: #TRUE to duplicate allocated data, otherwise #FALSE. * * Duplicates an #FbApiUser. The returned #FbApiUser should be freed with * #fb_api_user_free() when no longer needed. @@ -928,7 +924,7 @@ * Returns: The new #FbApiUser. */ FbApiUser * -fb_api_user_dup(const FbApiUser *user, gboolean deep); +fb_api_user_dup(const FbApiUser *user); /** * fb_api_user_reset:
--- a/libpurple/protocols/facebook/facebook.c Sun Mar 13 21:59:38 2022 -0500 +++ b/libpurple/protocols/facebook/facebook.c Sun Mar 13 21:59:39 2022 -0500 @@ -531,7 +531,7 @@ FB_ID_TO_STR(msg->uid, uid); if (purple_blist_find_buddy(acct, uid) == NULL) { - msg = fb_api_message_dup(msg, TRUE); + msg = fb_api_message_dup(msg); fb_data_add_message(fata, msg); fb_api_contact(api, msg->uid); continue; @@ -548,7 +548,7 @@ if (msg->flags & FB_API_MESSAGE_FLAG_IMAGE) { if (!(msg->flags & FB_API_MESSAGE_FLAG_DONE)) { - msg = fb_api_message_dup(msg, TRUE); + msg = fb_api_message_dup(msg); fb_data_image_add(fata, msg->text, fb_cb_image, msg, (GDestroyNotify) fb_api_message_free);