[FFmpeg-devel] [PATCH] avutil/eval: Add av_expr_freep()

Michael Niedermayer michael at niedermayer.cc
Tue Jan 31 19:46:05 EET 2017


In many uses of av_expr_free() the pointer is NULLed afterwards, this should
allow simplifying such code

TODO: add bump& APIChanges

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavutil/eval.c | 7 +++++++
 libavutil/eval.h | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/libavutil/eval.c b/libavutil/eval.c
index 7e866155db..b926ddb8bf 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -327,6 +327,13 @@ void av_expr_free(AVExpr *e)
     av_freep(&e);
 }
 
+void av_expr_freep(AVExpr **e)
+{
+    if(!e) return;
+    av_expr_free(*e);
+    *e = NULL;
+}
+
 static int parse_primary(AVExpr **e, Parser *p)
 {
     AVExpr *d = av_mallocz(sizeof(AVExpr));
diff --git a/libavutil/eval.h b/libavutil/eval.h
index dacd22b96e..8653b74a55 100644
--- a/libavutil/eval.h
+++ b/libavutil/eval.h
@@ -92,6 +92,12 @@ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
 void av_expr_free(AVExpr *e);
 
 /**
+ * Free a parsed expression previously created with av_expr_parse() and NULL its
+ * pointer.
+ */
+void av_expr_freep(AVExpr **e);
+
+/**
  * Parse the string in numstr and return its value as a double. If
  * the string is empty, contains only whitespaces, or does not contain
  * an initial substring that has the expected syntax for a
-- 
2.11.0



More information about the ffmpeg-devel mailing list