ext/gnomevfs/gstgnomevfssrc.c: Fix memleaks, GST_BUFFER_DATA() is not freed.
authorWim Taymans <wim.taymans@gmail.com>
Wed, 25 May 2005 11:59:39 +0000 (11:59 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 25 May 2005 11:59:39 +0000 (11:59 +0000)
Original commit message from CVS:
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create):
Fix memleaks, GST_BUFFER_DATA() is not freed.

ChangeLog
ext/gnomevfs/gstgnomevfssrc.c

index c608548..f0b7f06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-05-25  Wim Taymans  <wim@fluendo.com>
 
+       * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create):
+       Fix memleaks, GST_BUFFER_DATA() is not freed.
+
+2005-05-25  Wim Taymans  <wim@fluendo.com>
+
        * ext/alsa/gstalsasink.c: (gst_alsasink_open):
        Open non-blocking, set to blocking mode afterwards to avoid
        lockups when audio device is busy.
index 09d0b30..cee1404 100644 (file)
@@ -958,13 +958,12 @@ gst_gnomevfssrc_create (GstBaseSrc * basesrc, guint64 offset, guint size,
     }
   }
 
-  /* create the buffer */
-  buf = gst_buffer_new ();
-
   audiocast_do_notifications (src);
 
   if (src->iradio_mode && src->icy_metaint > 0) {
-    data = g_malloc (src->icy_metaint);
+    buf = gst_buffer_new_and_alloc (src->icy_metaint);
+
+    data = GST_BUFFER_DATA (buf);
 
     /* try to read */
     GST_DEBUG ("doing read: icy_count: %" G_GINT64_FORMAT, src->icy_count);
@@ -980,8 +979,7 @@ gst_gnomevfssrc_create (GstBaseSrc * basesrc, guint64 offset, guint size,
 
     src->icy_count += readbytes;
     GST_BUFFER_OFFSET (buf) = src->curoffset;
-    GST_BUFFER_SIZE (buf) += readbytes;
-    GST_BUFFER_DATA (buf) = data;
+    GST_BUFFER_SIZE (buf) = readbytes;
     src->curoffset += readbytes;
 
     if (src->icy_count == src->icy_metaint) {
@@ -989,20 +987,21 @@ gst_gnomevfssrc_create (GstBaseSrc * basesrc, guint64 offset, guint size,
       src->icy_count = 0;
     }
   } else {
-    data = g_malloc (size);
+    buf = gst_buffer_new_and_alloc (size);
+
+    data = GST_BUFFER_DATA (buf);
+    GST_BUFFER_OFFSET (buf) = src->curoffset;
 
     res = gnome_vfs_read (src->handle, data, size, &readbytes);
 
+    GST_BUFFER_SIZE (buf) = readbytes;
+
     if (res != GNOME_VFS_OK)
       goto read_failed;
 
     if (readbytes == 0)
       goto eos;
 
-    GST_BUFFER_OFFSET (buf) = src->curoffset;
-    GST_BUFFER_SIZE (buf) = readbytes;
-    GST_BUFFER_DATA (buf) = data;
-
     src->curoffset += readbytes;
   }