[vlc-devel] [PATCH v3 08/12] picture: allow NULL gc callback

Steve Lhomme robux4 at ycbcr.xyz
Tue Aug 18 08:24:49 CEST 2020


No need to use a dummy one if we don't have to.
---
 src/misc/picture.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/src/misc/picture.c b/src/misc/picture.c
index ecb15611d1d..5aee1241e90 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -51,15 +51,6 @@ static void PictureDestroyContext( picture_t *p_picture )
     }
 }
 
-/**
- * Destroys a picture allocated by picture_NewFromResource() but without
- * a custom destruction callback.
- */
-static void picture_DestroyDummy( picture_t *p_picture )
-{
-    (void) p_picture;
-}
-
 /**
  * Destroys a picture allocated with picture_NewFromFormat().
  */
@@ -211,9 +202,7 @@ static bool picture_InitPrivate(const video_format_t *restrict p_fmt,
 
     atomic_init(&p_picture->refs, 1);
 
-    if ( p_resource == NULL)
-        priv->gc.destroy = picture_DestroyDummy;
-    else
+    if ( p_resource != NULL)
     {
         p_picture->p_sys = p_resource->p_sys;
         priv->gc.opaque  = p_resource->p_sys;
@@ -333,8 +322,8 @@ void picture_Destroy(picture_t *picture)
     PictureDestroyContext(picture);
 
     picture_priv_t *priv = container_of(picture, picture_priv_t, picture);
-    assert(priv->gc.destroy != NULL);
-    priv->gc.destroy(picture);
+    if (priv->gc.destroy != NULL)
+        priv->gc.destroy(picture);
     free(priv);
 }
 
-- 
2.26.2



More information about the vlc-devel mailing list