[PATCH 2/5] libmm-glib: use g_list_copy_deep for deep copying a GList

Ben Chan benchan at chromium.org
Fri Jun 23 16:11:05 UTC 2017


---
 libmm-glib/mm-modem-messaging.c | 3 +--
 libmm-glib/mm-modem-voice.c     | 3 +--
 libmm-glib/mm-modem.c           | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libmm-glib/mm-modem-messaging.c b/libmm-glib/mm-modem-messaging.c
index d732dd88..bcc85728 100644
--- a/libmm-glib/mm-modem-messaging.c
+++ b/libmm-glib/mm-modem-messaging.c
@@ -273,8 +273,7 @@ mm_modem_messaging_list_finish (MMModemMessaging *self,
 
     /* The list we got, including the objects within, is owned by the async result;
      * so we'll make sure we return a new list */
-    g_list_foreach (list, (GFunc)g_object_ref, NULL);
-    return g_list_copy (list);
+    return g_list_copy_deep (list, (GCopyFunc)g_object_ref, NULL);
 }
 
 static void create_next_sms (ListSmsContext *ctx);
diff --git a/libmm-glib/mm-modem-voice.c b/libmm-glib/mm-modem-voice.c
index 76cd7b6d..db3d329d 100644
--- a/libmm-glib/mm-modem-voice.c
+++ b/libmm-glib/mm-modem-voice.c
@@ -138,8 +138,7 @@ mm_modem_voice_list_calls_finish (MMModemVoice *self,
 
     /* The list we got, including the objects within, is owned by the async result;
      * so we'll make sure we return a new list */
-    g_list_foreach (list, (GFunc)g_object_ref, NULL);
-    return g_list_copy (list);
+    return g_list_copy_deep (list, (GCopyFunc)g_object_ref, NULL);
 }
 
 static void create_next_call (ListCallsContext *ctx);
diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c
index 6a29853e..9bbd978b 100644
--- a/libmm-glib/mm-modem.c
+++ b/libmm-glib/mm-modem.c
@@ -1806,8 +1806,7 @@ mm_modem_list_bearers_finish (MMModem *self,
 
     /* The list we got, including the objects within, is owned by the async result;
      * so we'll make sure we return a new list */
-    g_list_foreach (list, (GFunc)g_object_ref, NULL);
-    return g_list_copy (list);
+    return g_list_copy_deep (list, (GCopyFunc)g_object_ref, NULL);
 }
 
 static void create_next_bearer (ListBearersContext *ctx);
-- 
2.13.1.611.g7e3b11ae1-goog



More information about the ModemManager-devel mailing list