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

Submitted by Michael Niedermayer on Jan. 31, 2017, 5:46 p.m.

Details

Message ID 20170131174605.21326-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 31, 2017, 5:46 p.m.
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@niedermayer.cc>
---
 libavutil/eval.c | 7 +++++++
 libavutil/eval.h | 6 ++++++
 2 files changed, 13 insertions(+)

Patch hide | download patch | download mbox

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