From 0691278377e79ba5463f6f66ae2878160909de47 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 Apr 2018 18:28:00 +0100 Subject: [PATCH] buffer: don't over-allocate internal GstMeta items 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 5e61cbc..38a7a70 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -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 -- 2.7.4