From 75c81c2120b4f04c0e58444d8332e1f5ab402e42 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 6 Jul 2011 15:13:30 +0100 Subject: [PATCH] buffer: make idx argument to gst_buffer_take_memory() signed Since -1 is acceptable, it should be signed. --- gst/gstbuffer.c | 13 +++++++------ gst/gstbuffer.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 4380f7a..59911f1 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -583,19 +583,20 @@ gst_buffer_n_memory (GstBuffer * buffer) /** * gst_buffer_take_memory: * @buffer: a #GstBuffer. - * @idx: the index to add the memory - * @mem: a #GstMemory. + * @idx: the index to add the memory at, or -1 to append it to the end + * @mem: (transfer: full): a #GstMemory. * - * Add the memory block @mem to @buffer at @idx. This function takes ownership of @mem - * and thus doesn't increase its refcount. + * Add the memory block @mem to @buffer at @idx. This function takes ownership + * of @mem and thus doesn't increase its refcount. */ void -gst_buffer_take_memory (GstBuffer * buffer, guint idx, GstMemory * mem) +gst_buffer_take_memory (GstBuffer * buffer, gint idx, GstMemory * mem) { g_return_if_fail (GST_IS_BUFFER (buffer)); g_return_if_fail (gst_buffer_is_writable (buffer)); g_return_if_fail (mem != NULL); - g_return_if_fail (idx == -1 || idx <= GST_BUFFER_MEM_LEN (buffer)); + g_return_if_fail (idx == -1 || + (idx >= 0 && idx <= GST_BUFFER_MEM_LEN (buffer))); _memory_add (buffer, idx, mem); } diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index cead4c7..d5d3c9a 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -230,7 +230,7 @@ GstBuffer * gst_buffer_new_allocate (const GstAllocator * allocator, gsiz /* memory blocks */ guint gst_buffer_n_memory (GstBuffer *buffer); -void gst_buffer_take_memory (GstBuffer *buffer, guint idx, GstMemory *mem); +void gst_buffer_take_memory (GstBuffer *buffer, gint idx, GstMemory *mem); GstMemory * gst_buffer_peek_memory (GstBuffer *buffer, guint idx, GstMapFlags flags); void gst_buffer_remove_memory_range (GstBuffer *buffer, guint idx, guint length); -- 2.7.4