buffer: don't over-allocate internal GstMeta items
authorTim-Philipp Müller <tim@centricular.com>
Wed, 25 Apr 2018 17:28:00 +0000 (18:28 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 25 Apr 2018 17:28:00 +0000 (18:28 +0100)
We would allocate space for two GstMeta structs even though
there is only one in the end (the one in GstMetaItem and in
GstFooMeta overlap).

gst/gstbuffer.c

index 5e61cbc..38a7a70 100644 (file)
@@ -140,7 +140,10 @@ struct _GstMetaItem
   GstMetaItem *next;
   GstMeta meta;
 };
-#define ITEM_SIZE(info) ((info)->size + sizeof (GstMetaItem))
+
+/* info->size will be sizeof(FooMeta) which contains a GstMeta at the beginning
+ * too, and then there is again a GstMeta in GstMetaItem, so subtract one. */
+#define ITEM_SIZE(info) ((info)->size + sizeof (GstMetaItem) - sizeof (GstMeta))
 
 #define GST_BUFFER_MEM_MAX         16