2004-03-31 David Schleef <ds@schleef.org>
+ * 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 <ds@schleef.org>
+
* 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
* 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.
*/
}
/**
+ * 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.
/* 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);