[perl-GStreamer] GStreamer::Buffer: do not leak all data
- From: Torsten SchÃnfeld <tsch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perl-GStreamer] GStreamer::Buffer: do not leak all data
- Date: Sat, 18 Feb 2012 16:04:14 +0000 (UTC)
commit d26bd4e433133df222b75c7ebf5b50882a15d87e
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date: Sat Feb 18 17:04:00 2012 +0100
GStreamer::Buffer: do not leak all data
NEWS | 5 +++++
xs/GstBuffer.xs | 21 ++++++++++++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6ab8028..5314743 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Overview of changes in GStreamer <next>
+=====================================
+
+* Make GStreamer::Buffer not leak all data.
+
Overview of changes in GStreamer 0.16
=====================================
diff --git a/xs/GstBuffer.xs b/xs/GstBuffer.xs
index f065543..0d56d06 100644
--- a/xs/GstBuffer.xs
+++ b/xs/GstBuffer.xs
@@ -95,11 +95,26 @@ gst_buffer_set_data (buf, data)
GstBuffer *buf
SV *data
PREINIT:
- int length = sv_len (data);
+ STRLEN length;
+ gchar *raw_data;
CODE:
- /* FIXME: Hot to get rid of the leak? */
+ if (buf->malloc_data) {
+#if GST_CHECK_VERSION (0, 10, 22)
+ if (buf->free_func)
+ buf->free_func (buf->malloc_data);
+ else
+ g_free (buf->malloc_data);
+#else
+ g_free (buf->malloc_data);
+#endif
+ }
+ raw_data = SvPV (data, length);
+ buf->malloc_data = (guchar*) g_strndup (raw_data, length);
+#if GST_CHECK_VERSION (0, 10, 22)
+ buf->free_func = g_free;
+#endif
gst_buffer_set_data (buf,
- (guchar *) g_strndup (SvPV_nolen (data), length),
+ buf->malloc_data,
length);
GstCaps_own_ornull * gst_buffer_get_caps (GstBuffer *buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]