iterator: store size in the struct

https://bugzilla.gnome.org/show_bug.cgi?id=638987
This commit is contained in:
Johan Dahlin 2011-01-08 12:07:55 -02:00 committed by Sebastian Dröge
parent dc63e38219
commit 47ebd0755b
2 changed files with 9 additions and 6 deletions

View file

@ -71,13 +71,14 @@
#include "gst_private.h" #include "gst_private.h"
#include <gst/gstiterator.h> #include <gst/gstiterator.h>
/* FIXME 0.11: Store the size inside the iterator, use GSlice for allocation /* FIXME 0.11: use GSlice for allocation and let gst_iterator_free() free
* and let gst_iterator_free() free the memory while the free-func only frees * the memory while the free-func only frees additional resources
* additional resources (maybe call it finalize?). * (maybe call it finalize?).
*/ */
static void static void
gst_iterator_init (GstIterator * it, gst_iterator_init (GstIterator * it,
guint size,
GType type, GType type,
GMutex * lock, GMutex * lock,
guint32 * master_cookie, guint32 * master_cookie,
@ -85,6 +86,7 @@ gst_iterator_init (GstIterator * it,
GstIteratorItemFunction item, GstIteratorItemFunction item,
GstIteratorResyncFunction resync, GstIteratorFreeFunction free) GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
{ {
it->size = size;
it->type = type; it->type = type;
it->lock = lock; it->lock = lock;
it->master_cookie = master_cookie; it->master_cookie = master_cookie;
@ -137,8 +139,8 @@ gst_iterator_new (guint size,
g_return_val_if_fail (free != NULL, NULL); g_return_val_if_fail (free != NULL, NULL);
result = g_malloc (size); result = g_malloc (size);
gst_iterator_init (result, type, lock, master_cookie, next, item, resync, gst_iterator_init (result, size, type, lock, master_cookie, next, item,
free); resync, free);
return result; return result;
} }

View file

@ -216,9 +216,10 @@ struct _GstIterator {
guint32 cookie; /* cookie of the iterator */ guint32 cookie; /* cookie of the iterator */
guint32 *master_cookie; /* pointer to guint32 holding the cookie when this guint32 *master_cookie; /* pointer to guint32 holding the cookie when this
iterator was created */ iterator was created */
guint size;
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING-1];
}; };
/* creating iterators */ /* creating iterators */