rtp{vorbis,theora}{pay,depay}: Cosmetic cleanup
authorSebastian Rasmussen <sebras@hotmail.com>
Sat, 19 Sep 2015 15:04:07 +0000 (17:04 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Sun, 20 Sep 2015 08:13:38 +0000 (10:13 +0200)
* use g_list_free_full(), don't iterate elements maually when freeing
* call gst_rtp_*_pay_clear_packet(), don't duplicate its code
* use gst_buffer_unref() to clarify that it is buffers being released,
  instead of refering directly to gst_mini_object_unref()

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=755277

gst/rtp/gstrtptheorapay.c
gst/rtp/gstrtpvorbisdepay.c
gst/rtp/gstrtpvorbispay.c

index cf5c485..802a335 100644 (file)
@@ -153,22 +153,17 @@ gst_rtp_theora_pay_clear_packet (GstRtpTheoraPay * rtptheorapay)
   if (rtptheorapay->packet)
     gst_buffer_unref (rtptheorapay->packet);
   rtptheorapay->packet = NULL;
-
-  g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref,
-      NULL);
-  g_list_free (rtptheorapay->packet_buffers);
+  g_list_free_full (rtptheorapay->packet_buffers,
+      (GDestroyNotify) gst_buffer_unref);
   rtptheorapay->packet_buffers = NULL;
 }
 
 static void
 gst_rtp_theora_pay_cleanup (GstRtpTheoraPay * rtptheorapay)
 {
-  g_list_foreach (rtptheorapay->headers, (GFunc) gst_mini_object_unref, NULL);
-  g_list_free (rtptheorapay->headers);
-  rtptheorapay->headers = NULL;
-
   gst_rtp_theora_pay_clear_packet (rtptheorapay);
-
+  g_list_free_full (rtptheorapay->headers, (GDestroyNotify) gst_buffer_unref);
+  rtptheorapay->headers = NULL;
   if (rtptheorapay->config_data)
     g_free (rtptheorapay->config_data);
   rtptheorapay->config_data = NULL;
@@ -283,13 +278,7 @@ gst_rtp_theora_pay_init_packet (GstRtpTheoraPay * rtptheorapay, guint8 TDT,
 {
   GST_DEBUG_OBJECT (rtptheorapay, "starting new packet, TDT: %d", TDT);
 
-  if (rtptheorapay->packet)
-    gst_buffer_unref (rtptheorapay->packet);
-
-  g_list_foreach (rtptheorapay->packet_buffers, (GFunc) gst_mini_object_unref,
-      NULL);
-  g_list_free (rtptheorapay->packet_buffers);
-  rtptheorapay->packet_buffers = NULL;
+  gst_rtp_theora_pay_clear_packet (rtptheorapay);
 
   /* new packet allocate max packet size */
   rtptheorapay->packet =
index bc13a04..bd2f78f 100644 (file)
@@ -113,26 +113,14 @@ gst_rtp_vorbis_depay_init (GstRtpVorbisDepay * rtpvorbisdepay)
 static void
 free_config (GstRtpVorbisConfig * conf)
 {
-  GList *headers;
-
-  for (headers = conf->headers; headers; headers = g_list_next (headers)) {
-    GstBuffer *header = GST_BUFFER_CAST (headers->data);
-
-    gst_buffer_unref (header);
-  }
-  g_list_free (conf->headers);
+  g_list_free_full (conf->headers, (GDestroyNotify) gst_buffer_unref);
   g_free (conf);
 }
 
 static void
 free_indents (GstRtpVorbisDepay * rtpvorbisdepay)
 {
-  GList *walk;
-
-  for (walk = rtpvorbisdepay->configs; walk; walk = g_list_next (walk)) {
-    free_config ((GstRtpVorbisConfig *) walk->data);
-  }
-  g_list_free (rtpvorbisdepay->configs);
+  g_list_free_full (rtpvorbisdepay->configs, (GDestroyNotify) free_config);
   rtpvorbisdepay->configs = NULL;
 }
 
index bd8ee41..4350705 100644 (file)
@@ -145,21 +145,17 @@ gst_rtp_vorbis_pay_clear_packet (GstRtpVorbisPay * rtpvorbispay)
   if (rtpvorbispay->packet)
     gst_buffer_unref (rtpvorbispay->packet);
   rtpvorbispay->packet = NULL;
-  g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref,
-      NULL);
-  g_list_free (rtpvorbispay->packet_buffers);
+  g_list_free_full (rtpvorbispay->packet_buffers,
+      (GDestroyNotify) gst_buffer_unref);
   rtpvorbispay->packet_buffers = NULL;
 }
 
 static void
 gst_rtp_vorbis_pay_cleanup (GstRtpVorbisPay * rtpvorbispay)
 {
-  g_list_foreach (rtpvorbispay->headers, (GFunc) gst_mini_object_unref, NULL);
-  g_list_free (rtpvorbispay->headers);
-  rtpvorbispay->headers = NULL;
-
   gst_rtp_vorbis_pay_clear_packet (rtpvorbispay);
-
+  g_list_free_full (rtpvorbispay->headers, (GDestroyNotify) gst_buffer_unref);
+  rtpvorbispay->headers = NULL;
   if (rtpvorbispay->config_data)
     g_free (rtpvorbispay->config_data);
   rtpvorbispay->config_data = NULL;
@@ -277,12 +273,7 @@ gst_rtp_vorbis_pay_init_packet (GstRtpVorbisPay * rtpvorbispay, guint8 VDT,
 {
   GST_LOG_OBJECT (rtpvorbispay, "starting new packet, VDT: %d", VDT);
 
-  if (rtpvorbispay->packet)
-    gst_buffer_unref (rtpvorbispay->packet);
-  g_list_foreach (rtpvorbispay->packet_buffers, (GFunc) gst_mini_object_unref,
-      NULL);
-  g_list_free (rtpvorbispay->packet_buffers);
-  rtpvorbispay->packet_buffers = NULL;
+  gst_rtp_vorbis_pay_clear_packet (rtpvorbispay);
 
   /* new packet allocate max packet size */
   rtpvorbispay->packet =