From: David Schleef Date: Thu, 1 Apr 2004 00:40:26 +0000 (+0000) Subject: gst/gstbuffer.c: (gst_buffer_join): Add function gst_buffer_join() to eventually... X-Git-Tag: RELEASE-0_8_1~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cf56f6b30c7e171cb875737baa78e41bc4087550;p=platform%2Fupstream%2Fgstreamer.git gst/gstbuffer.c: (gst_buffer_join): Add function gst_buffer_join() to eventually deprecate gst_buffer_merge(). (bug... Original commit message from CVS: * gst/gstbuffer.c: (gst_buffer_join): Add function gst_buffer_join() to eventually deprecate gst_buffer_merge(). (bug: #136408) * gst/gstbuffer.h: --- diff --git a/ChangeLog b/ChangeLog index 7c8c3e5..8e8310c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2004-03-31 David Schleef + * gst/gstbuffer.c: (gst_buffer_join): Add function gst_buffer_join() + to eventually deprecate gst_buffer_merge(). (bug: #136408) + * gst/gstbuffer.h: + +2004-03-31 David Schleef + * gst/gstvalue.c: (gst_value_union_int_int_range), (gst_value_union_int_range_int_range), (gst_value_can_union), (gst_value_union), (_gst_value_initialize): Add some union diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 325a9c2..474ec0d 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -318,8 +318,11 @@ gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size) * buffers. The original source buffers will not be modified or * unref'd. * - * Internally is nothing more than a specialized gst_buffer_span(), - * so the same optimizations can occur. + * WARNING: Incorrect use of this function can lead to memory leaks. + * It is recommended to use gst_buffer_join() instead of this function. + * + * If the buffers point to contiguous areas of memory, the buffer + * is created without copying the data. * * Returns: the new #GstBuffer that's the concatenation of the source buffers. */ @@ -335,6 +338,33 @@ gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2) } /** + * gst_buffer_join: + * @buf1: a first source #GstBuffer to merge. + * @buf2: the second source #GstBuffer to merge. + * + * Create a new buffer that is the concatenation of the two source + * buffers. The original buffers are unreferenced. + * + * If the buffers point to contiguous areas of memory, the buffer + * is created without copying the data. + * + * Returns: the new #GstBuffer that's the concatenation of the source buffers. + */ +GstBuffer * +gst_buffer_join (GstBuffer * buf1, GstBuffer * buf2) +{ + GstBuffer *result; + + /* we're just a specific case of the more general gst_buffer_span() */ + result = gst_buffer_span (buf1, 0, buf2, buf1->size + buf2->size); + + gst_buffer_unref (buf1); + gst_buffer_unref (buf2); + + return result; +} + +/** * gst_buffer_is_span_fast: * @buf1: a first source #GstBuffer. * @buf2: the second source #GstBuffer. diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 8fb65b1..7731453 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -138,6 +138,7 @@ GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size); /* merge, span, or append two buffers, intelligently */ GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2); +GstBuffer* gst_buffer_join (GstBuffer *buf1, GstBuffer *buf2); gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2); GstBuffer* gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len);