From cc7985ab4860d0386686bcbbf0ce17d04a72bf48 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 May 2009 22:51:18 +0200 Subject: [PATCH] adapter: use g_realloc for resizing the buffer Use g_realloc for resizing the internal buffer instead of a less fancy _free/_malloc pair. --- libs/gst/base/gstadapter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c index 047bae3e53..914330192b 100644 --- a/libs/gst/base/gstadapter.c +++ b/libs/gst/base/gstadapter.c @@ -398,12 +398,12 @@ gst_adapter_peek (GstAdapter * adapter, guint size) } /* Gonna need to copy stuff out */ - if (adapter->assembled_size < size) { + if (G_UNLIKELY (adapter->assembled_size < size)) { adapter->assembled_size = (size / DEFAULT_SIZE + 1) * DEFAULT_SIZE; - GST_DEBUG_OBJECT (adapter, "setting size of internal buffer to %u", + GST_DEBUG_OBJECT (adapter, "resizing internal buffer to %u", adapter->assembled_size); - g_free (adapter->assembled_data); - adapter->assembled_data = g_malloc (adapter->assembled_size); + adapter->assembled_data = + g_realloc (adapter->assembled_data, adapter->assembled_size); } adapter->assembled_len = size;