From b23279e922e19e134029869f3fd48900e7d432a5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 13 May 2009 23:52:02 +0200 Subject: [PATCH] adapter: don't use realloc, it does a memcpy Don't use realloc to grow the scratch area because we don't want the memcpy the old useless data into the new area before we write our new stuff in it. --- libs/gst/base/gstadapter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/gst/base/gstadapter.c b/libs/gst/base/gstadapter.c index 914330192b..0acfd3872b 100644 --- a/libs/gst/base/gstadapter.c +++ b/libs/gst/base/gstadapter.c @@ -402,8 +402,10 @@ gst_adapter_peek (GstAdapter * adapter, guint size) adapter->assembled_size = (size / DEFAULT_SIZE + 1) * DEFAULT_SIZE; GST_DEBUG_OBJECT (adapter, "resizing internal buffer to %u", adapter->assembled_size); - adapter->assembled_data = - g_realloc (adapter->assembled_data, adapter->assembled_size); + /* no g_realloc to avoid a memcpy that is not desired here since we are + * going to copy new data into the area below */ + g_free (adapter->assembled_data); + adapter->assembled_data = g_malloc (adapter->assembled_size); } adapter->assembled_len = size;