From 2b17de7504df1857b282981f9cae4462c6fa7365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 14 Jul 2012 19:38:39 +0100 Subject: [PATCH] plugins: add init/clear functions to GstQueueArray --- plugins/elements/gstqueuearray.c | 23 ++++++++++++++++++----- plugins/elements/gstqueuearray.h | 3 +++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/elements/gstqueuearray.c b/plugins/elements/gstqueuearray.c index 9e2ed548b7..f16f7ae017 100644 --- a/plugins/elements/gstqueuearray.c +++ b/plugins/elements/gstqueuearray.c @@ -23,17 +23,24 @@ #include #include "gstqueuearray.h" -GstQueueArray * -gst_queue_array_new (guint initial_size) +void +gst_queue_array_init (GstQueueArray * array, guint initial_size) { - GstQueueArray *array = g_malloc (sizeof (GstQueueArray)); - array->size = initial_size; array->array = g_new0 (gpointer, initial_size); array->head = 0; array->tail = 0; array->length = 0; +} + +GstQueueArray * +gst_queue_array_new (guint initial_size) +{ + GstQueueArray *array; + + array = g_new (GstQueueArray, 1); + gst_queue_array_init (array, initial_size); return array; } @@ -102,9 +109,15 @@ gst_queue_array_is_empty (GstQueueArray * array) } void -gst_queue_array_free (GstQueueArray * array) +gst_queue_array_clear (GstQueueArray * array) { g_free (array->array); +} + +void +gst_queue_array_free (GstQueueArray * array) +{ + gst_queue_array_clear (array); g_free (array); } diff --git a/plugins/elements/gstqueuearray.h b/plugins/elements/gstqueuearray.h index 0c79540574..dd2899346a 100644 --- a/plugins/elements/gstqueuearray.h +++ b/plugins/elements/gstqueuearray.h @@ -35,6 +35,9 @@ struct _GstQueueArray guint length; }; +void gst_queue_array_init (GstQueueArray * array, guint initial_size); +void gst_queue_array_clear (GstQueueArray * array); + GstQueueArray *gst_queue_array_new (guint initial_size); gpointer gst_queue_array_pop_head (GstQueueArray * array); void gst_queue_array_push_tail (GstQueueArray * array, gpointer data);