[vlc-devel] [PATCH 07/19] picture: allow NULL gc callback

Steve Lhomme robux4 at ycbcr.xyz
Thu Jul 30 14:16:48 CEST 2020


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

diff --git a/src/misc/picture.c b/src/misc/picture.c
index 92e5087f648..8d3d4f80be4 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().
  */
@@ -226,7 +217,7 @@ picture_t *picture_NewFromResource( const video_format_t *p_fmt, const picture_r
     }
 
     priv->gc = (picture_gc_t) {
-        p_resource->pf_destroy ? p_resource->pf_destroy : picture_DestroyDummy,
+        p_resource->pf_destroy,
         p_resource->p_sys,
     };
 
@@ -271,7 +262,7 @@ picture_t *picture_NewFromFormat(const video_format_t *restrict fmt)
     if (pic->i_planes == 0) {
         pic->p_sys = NULL;
         // we allocated a picture_priv_buffer_t for nothing
-        priv->gc = (picture_gc_t) { picture_DestroyDummy, NULL };
+        priv->gc = (picture_gc_t) { NULL, NULL };
         return pic;
     }
 
@@ -340,8 +331,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