From patchwork Tue Jan 31 17:46:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 2381 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp2052215vsb; Tue, 31 Jan 2017 09:46:15 -0800 (PST) X-Received: by 10.223.134.253 with SMTP id 58mr29452278wry.46.1485884775713; Tue, 31 Jan 2017 09:46:15 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t82si18127655wmg.0.2017.01.31.09.46.15; Tue, 31 Jan 2017 09:46:15 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 665A368A482; Tue, 31 Jan 2017 19:46:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-2.mx.upcmail.net (vie01a-dmta-pe02-2.mx.upcmail.net [62.179.121.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC01268A334 for ; Tue, 31 Jan 2017 19:46:04 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.87) (envelope-from ) id 1cYcVK-0007V4-Oo for ffmpeg-devel@ffmpeg.org; Tue, 31 Jan 2017 18:46:06 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id f5m51u02d0S5wYM015m6ND; Tue, 31 Jan 2017 18:46:06 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 31 Jan 2017 18:46:05 +0100 Message-Id: <20170131174605.21326-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.11.0 Subject: [FFmpeg-devel] [PATCH] avutil/eval: Add av_expr_freep() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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