[FFmpeg-devel] [PATCH] ffprobe: prefer av_strtok_r() over av_get_token() for parsing print_fmt string

Stefano Sabatini stefasab at gmail.com
Sat Oct 15 12:50:49 CEST 2011


Simplify, and avoid the need for multiple levels of escaping.
---
 ffprobe.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index dfbb0ae..e78c9c5 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -1265,18 +1265,15 @@ static int probe_file(const char *filename)
     AVFormatContext *fmt_ctx;
     int ret;
     Writer *w;
-    const char *buf = print_format;
+    char *buf0 = av_strdup(print_format), *buf;
     char *w_str = NULL, *w_args = NULL;
     WriterContext *wctx;
 
     writer_register_all();
 
     if (buf) {
-        w_str = av_get_token(&buf, "=");
-        if (*buf == '=') {
-            buf++;
-            w_args = av_get_token(&buf, "");
-        }
+        w_str = av_strtok_r(buf0, "=", &buf);
+        w_args = buf;
     }
 
     if (!w_str)
@@ -1304,8 +1301,7 @@ static int probe_file(const char *filename)
     writer_close(&wctx);
 
 end:
-    av_free(w_str);
-    av_free(w_args);
+    av_free(buf0);
 
     return ret;
 }
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list