[vlc-commits] picture: allow extra private data in picture_priv_t

Rémi Denis-Courmont git at videolan.org
Sun Oct 28 11:18:18 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 27 18:35:17 2018 +0300| [e7c9ac3d6335f5eadbf4b412cdafb5f11d6de438] | committer: Rémi Denis-Courmont

picture: allow extra private data in picture_priv_t

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e7c9ac3d6335f5eadbf4b412cdafb5f11d6de438
---

 src/misc/picture.c | 9 +++++----
 src/misc/picture.h | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index f61e0a3d0e..4cdbf8193a 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -178,10 +178,11 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
  *
  *****************************************************************************/
 
-static picture_priv_t *picture_NewPrivate(const video_format_t *restrict p_fmt)
+static picture_priv_t *picture_NewPrivate(const video_format_t *restrict p_fmt,
+                                          size_t extra)
 {
     /* */
-    picture_priv_t *priv = malloc( sizeof (*priv) );
+    picture_priv_t *priv = malloc(sizeof (*priv) + extra);
     if( unlikely(priv == NULL) )
         return NULL;
 
@@ -207,7 +208,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
 {
     assert(p_resource != NULL);
 
-    picture_priv_t *priv = picture_NewPrivate(p_fmt);
+    picture_priv_t *priv = picture_NewPrivate(p_fmt, 0);
     if (unlikely(priv == NULL))
         return NULL;
 
@@ -234,7 +235,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
 
 picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
 {
-    picture_priv_t *priv = picture_NewPrivate(fmt);
+    picture_priv_t *priv = picture_NewPrivate(fmt, 0);
     if (unlikely(priv == NULL))
         return NULL;
 
diff --git a/src/misc/picture.h b/src/misc/picture.h
index 70ee64878d..a838144a6c 100644
--- a/src/misc/picture.h
+++ b/src/misc/picture.h
@@ -19,6 +19,7 @@
  *****************************************************************************/
 
 #include <stdatomic.h>
+#include <stddef.h>
 
 #include <vlc_picture.h>
 
@@ -31,4 +32,6 @@ typedef struct
         void (*destroy)(picture_t *);
         void *opaque;
     } gc;
+
+    max_align_t extra[];
 } picture_priv_t;



More information about the vlc-commits mailing list