event: no need to store the size of the structure inside the structure

This commit is contained in:
Tim-Philipp Müller 2012-06-14 23:52:41 +01:00
parent b4a9a2f79e
commit 7eecd8f56f

View file

@ -92,12 +92,9 @@ typedef struct
{ {
GstEvent event; GstEvent event;
gsize slice_size;
GstStructure *structure; GstStructure *structure;
} GstEventImpl; } GstEventImpl;
#define GST_EVENT_SLICE_SIZE(e) (((GstEventImpl *)(e))->slice_size)
#define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure) #define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure)
typedef struct typedef struct
@ -232,11 +229,10 @@ _gst_event_free (GstEvent * event)
gst_structure_free (s); gst_structure_free (s);
} }
g_slice_free1 (GST_EVENT_SLICE_SIZE (event), event); g_slice_free1 (sizeof (GstEventImpl), event);
} }
static void gst_event_init (GstEventImpl * event, gsize size, static void gst_event_init (GstEventImpl * event, GstEventType type);
GstEventType type);
static GstEvent * static GstEvent *
_gst_event_copy (GstEvent * event) _gst_event_copy (GstEvent * event)
@ -246,7 +242,7 @@ _gst_event_copy (GstEvent * event)
copy = g_slice_new0 (GstEventImpl); copy = g_slice_new0 (GstEventImpl);
gst_event_init (copy, sizeof (GstEventImpl), GST_EVENT_TYPE (event)); gst_event_init (copy, GST_EVENT_TYPE (event));
GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event); GST_EVENT_TIMESTAMP (copy) = GST_EVENT_TIMESTAMP (event);
GST_EVENT_SEQNUM (copy) = GST_EVENT_SEQNUM (event); GST_EVENT_SEQNUM (copy) = GST_EVENT_SEQNUM (event);
@ -263,15 +259,13 @@ _gst_event_copy (GstEvent * event)
} }
static void static void
gst_event_init (GstEventImpl * event, gsize size, GstEventType type) gst_event_init (GstEventImpl * event, GstEventType type)
{ {
gst_mini_object_init (GST_MINI_OBJECT_CAST (event), _gst_event_type); gst_mini_object_init (GST_MINI_OBJECT_CAST (event), _gst_event_type);
event->event.mini_object.copy = (GstMiniObjectCopyFunction) _gst_event_copy; event->event.mini_object.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
event->event.mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free; event->event.mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
GST_EVENT_SLICE_SIZE (event) = size;
GST_EVENT_TYPE (event) = type; GST_EVENT_TYPE (event) = type;
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE; GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
GST_EVENT_SEQNUM (event) = gst_util_seqnum_next (); GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
@ -314,7 +308,7 @@ gst_event_new_custom (GstEventType type, GstStructure * structure)
goto had_parent; goto had_parent;
} }
gst_event_init (event, sizeof (GstEventImpl), type); gst_event_init (event, type);
GST_EVENT_STRUCTURE (event) = structure; GST_EVENT_STRUCTURE (event) = structure;
@ -323,7 +317,7 @@ gst_event_new_custom (GstEventType type, GstStructure * structure)
/* ERRORS */ /* ERRORS */
had_parent: had_parent:
{ {
g_slice_free1 (GST_EVENT_SLICE_SIZE (event), event); g_slice_free1 (sizeof (GstEventImpl), event);
g_warning ("structure is already owned by another object"); g_warning ("structure is already owned by another object");
return NULL; return NULL;
} }