From 656e0f6acd63b37a2809c67db3dc323044de0259 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 May 2005 11:59:39 +0000 Subject: [PATCH] ext/gnomevfs/gstgnomevfssrc.c: Fix memleaks, GST_BUFFER_DATA() is not freed. Original commit message from CVS: * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create): Fix memleaks, GST_BUFFER_DATA() is not freed. --- ChangeLog | 5 +++++ ext/gnomevfs/gstgnomevfssrc.c | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index c608548eb9..f0b7f06b7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-25 Wim Taymans + + * ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_create): + Fix memleaks, GST_BUFFER_DATA() is not freed. + 2005-05-25 Wim Taymans * ext/alsa/gstalsasink.c: (gst_alsasink_open): diff --git a/ext/gnomevfs/gstgnomevfssrc.c b/ext/gnomevfs/gstgnomevfssrc.c index 09d0b30a08..cee1404729 100644 --- a/ext/gnomevfs/gstgnomevfssrc.c +++ b/ext/gnomevfs/gstgnomevfssrc.c @@ -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; }