From f63e0209bfa74c02634839d3c675579d57c689d9 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 5 Apr 2004 18:39:01 +0000 Subject: [PATCH] gst/gstbuffer.c: Allocate GstBuffer structures in one place. Original commit message from CVS: * gst/gstbuffer.c: (_gst_buffer_sub_free), (gst_buffer_default_free), (gst_buffer_default_copy), (gst_buffer_alloc_chunk), (gst_buffer_free_chunk), (gst_buffer_new), (gst_buffer_create_sub): Allocate GstBuffer structures in one place. --- ChangeLog | 8 ++++++++ gst/gstbuffer.c | 50 +++++++++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc15c12742..87f25436e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-04-05 David Schleef + + * gst/gstbuffer.c: (_gst_buffer_sub_free), + (gst_buffer_default_free), (gst_buffer_default_copy), + (gst_buffer_alloc_chunk), (gst_buffer_free_chunk), + (gst_buffer_new), (gst_buffer_create_sub): Allocate GstBuffer + structures in one place. + 2004-04-05 Thomas Vander Stichele * gst/gstinfo.h: adding Ronald's timestamp debugging defines diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 474ec0deb1..b7f88370de 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -39,6 +39,9 @@ static GstAllocTrace *_gst_buffer_trace; static GstMemChunk *chunk; +static GstBuffer *gst_buffer_alloc_chunk (void); +static void gst_buffer_free_chunk (GstBuffer * buffer); + void _gst_buffer_initialize (void) { @@ -71,10 +74,7 @@ _gst_buffer_sub_free (GstBuffer * buffer) _GST_DATA_DISPOSE (GST_DATA (buffer)); - gst_mem_chunk_free (chunk, GST_DATA (buffer)); -#ifndef GST_DISABLE_TRACE - gst_alloc_trace_free (_gst_buffer_trace, buffer); -#endif + gst_buffer_free_chunk (buffer); } /** @@ -102,10 +102,7 @@ gst_buffer_default_free (GstBuffer * buffer) _GST_DATA_DISPOSE (GST_DATA (buffer)); - gst_mem_chunk_free (chunk, GST_DATA (buffer)); -#ifndef GST_DISABLE_TRACE - gst_alloc_trace_free (_gst_buffer_trace, buffer); -#endif + gst_buffer_free_chunk (buffer); } /** @@ -144,10 +141,7 @@ gst_buffer_default_copy (GstBuffer * buffer) g_return_val_if_fail (buffer != NULL, NULL); /* create a fresh new buffer */ - copy = gst_mem_chunk_alloc (chunk); -#ifndef GST_DISABLE_TRACE - gst_alloc_trace_new (_gst_buffer_trace, copy); -#endif + copy = gst_buffer_alloc_chunk (); _GST_DATA_INIT (GST_DATA (copy), _gst_buffer_type, @@ -168,6 +162,28 @@ gst_buffer_default_copy (GstBuffer * buffer) return copy; } +static GstBuffer * +gst_buffer_alloc_chunk (void) +{ + GstBuffer *newbuf; + + newbuf = gst_mem_chunk_alloc (chunk); +#ifndef GST_DISABLE_TRACE + gst_alloc_trace_new (_gst_buffer_trace, newbuf); +#endif + + return newbuf; +} + +static void +gst_buffer_free_chunk (GstBuffer * buffer) +{ + gst_mem_chunk_free (chunk, GST_DATA (buffer)); +#ifndef GST_DISABLE_TRACE + gst_alloc_trace_free (_gst_buffer_trace, buffer); +#endif +} + /** * gst_buffer_new: * @@ -180,10 +196,7 @@ gst_buffer_new (void) { GstBuffer *newbuf; - newbuf = gst_mem_chunk_alloc (chunk); -#ifndef GST_DISABLE_TRACE - gst_alloc_trace_new (_gst_buffer_trace, newbuf); -#endif + newbuf = gst_buffer_alloc_chunk (); GST_CAT_LOG (GST_CAT_BUFFER, "new %p", newbuf); @@ -263,10 +276,7 @@ gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size) gst_data_ref (GST_DATA (parent)); /* create the new buffer */ - buffer = gst_mem_chunk_alloc (chunk); -#ifndef GST_DISABLE_TRACE - gst_alloc_trace_new (_gst_buffer_trace, buffer); -#endif + buffer = gst_buffer_alloc_chunk (); GST_CAT_LOG (GST_CAT_BUFFER, "new subbuffer %p (parent %p)", buffer, parent);