webrtc: Refactor ICECandidateStats freeing logic to a dedicated function
authorPhilippe Normand <philn@igalia.com>
Sat, 26 Mar 2022 12:36:46 +0000 (12:36 +0000)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 26 May 2022 10:54:59 +0000 (10:54 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1998>

subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.c
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcice.h
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c

index 8b1ce70..5e796e1 100644 (file)
@@ -1006,6 +1006,17 @@ gst_webrtc_ice_get_selected_pair (GstWebRTCICE * ice,
   return FALSE;
 }
 
+void
+gst_webrtc_ice_candidate_stats_free (GstWebRTCICECandidateStats * stats)
+{
+  if (stats) {
+    g_free (stats->ipaddr);
+    g_free (stats->url);
+  }
+
+  g_free (stats);
+}
+
 static void
 _clear_ice_stream (struct NiceStreamItem *item)
 {
index 831ca1c..7e20902 100644 (file)
@@ -128,6 +128,9 @@ gboolean                    gst_webrtc_ice_get_selected_pair        (GstWebRTCIC
                                                                      GstWebRTCICEStream * stream,
                                                                      GstWebRTCICECandidateStats ** local_stats,
                                                                      GstWebRTCICECandidateStats ** remote_stats);
+
+void                        gst_webrtc_ice_candidate_stats_free     (GstWebRTCICECandidateStats * stats);
+
 G_END_DECLS
 
 #endif /* __GST_WEBRTC_ICE_H__ */
index da3a4a6..c628fc1 100644 (file)
@@ -711,15 +711,8 @@ _get_stats_from_ice_transport (GstWebRTCBin * webrtc,
   g_free (local_cand_id);
   g_free (remote_cand_id);
 
-  if (local_cand) {
-    g_free (local_cand->ipaddr);
-    g_free (local_cand->url);
-  }
-  if (remote_cand)
-    g_free (remote_cand->ipaddr);
-
-  g_free (local_cand);
-  g_free (remote_cand);
+  gst_webrtc_ice_candidate_stats_free (local_cand);
+  gst_webrtc_ice_candidate_stats_free (remote_cand);
 
   gst_structure_free (stats);