[FFmpeg-cvslog] ffprobe: move up ESCAPE_CHECK_SIZE and ESCAPE_REALLOC_BUF macros

Stefano Sabatini git at videolan.org
Tue Oct 18 18:35:34 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Fri Oct 14 16:50:30 2011 +0200| [88bdf7471f6b8df5106f84b4b4d4cffe4606bcb0] | committer: Stefano Sabatini

ffprobe: move up ESCAPE_CHECK_SIZE and ESCAPE_REALLOC_BUF macros

So they can be used by other escaping routines.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=88bdf7471f6b8df5106f84b4b4d4cffe4606bcb0
---

 ffprobe.c |   50 +++++++++++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 0f5a2f9..e648922 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -335,6 +335,31 @@ fail:
     return NULL;
 }
 
+#define ESCAPE_INIT_BUF_SIZE 256
+
+#define ESCAPE_CHECK_SIZE(src, size, max_size)                          \
+    if (size > max_size) {                                              \
+        char buf[64];                                                   \
+        snprintf(buf, sizeof(buf), "%s", src);                          \
+        av_log(log_ctx, AV_LOG_WARNING,                                 \
+               "String '%s...' with is too big\n", buf);                \
+        return "FFPROBE_TOO_BIG_STRING";                                \
+    }
+
+#define ESCAPE_REALLOC_BUF(dst_size_p, dst_p, src, size)                \
+    if (*dst_size_p < size) {                                           \
+        char *q = av_realloc(*dst_p, size);                             \
+        if (!q) {                                                       \
+            char buf[64];                                               \
+            snprintf(buf, sizeof(buf), "%s", src);                      \
+            av_log(log_ctx, AV_LOG_WARNING,                             \
+                   "String '%s...' could not be escaped\n", buf);       \
+            return "FFPROBE_THIS_STRING_COULD_NOT_BE_ESCAPED";          \
+        }                                                               \
+        *dst_size_p = size;                                             \
+        *dst = q;                                                       \
+    }
+
 /* WRITERS */
 
 /* Default output */
@@ -414,8 +439,6 @@ typedef struct {
     size_t buf_size;
 } JSONContext;
 
-#define ESCAPE_INIT_BUF_SIZE 256
-
 static av_cold int json_init(WriterContext *wctx, const char *args, void *opaque)
 {
     JSONContext *json = wctx->priv;
@@ -433,29 +456,6 @@ static av_cold void json_uninit(WriterContext *wctx)
     av_freep(&json->buf);
 }
 
-#define ESCAPE_CHECK_SIZE(src, size, max_size)                          \
-    if (size > max_size) {                                              \
-        char buf[64];                                                   \
-        snprintf(buf, sizeof(buf), "%s", src);                          \
-        av_log(log_ctx, AV_LOG_WARNING,                                 \
-               "String '%s...' with is too big\n", buf);                \
-        return "FFPROBE_TOO_BIG_STRING";                                \
-    }
-
-#define ESCAPE_REALLOC_BUF(dst_size_p, dst_p, src, size)                \
-    if (*dst_size_p < size) {                                           \
-        char *q = av_realloc(*dst_p, size);                             \
-        if (!q) {                                                       \
-            char buf[64];                                               \
-            snprintf(buf, sizeof(buf), "%s", src);                      \
-            av_log(log_ctx, AV_LOG_WARNING,                             \
-                   "String '%s...' could not be escaped\n", buf);       \
-            return "FFPROBE_THIS_STRING_COULD_NOT_BE_ESCAPED";          \
-        }                                                               \
-        *dst_size_p = size;                                             \
-        *dst = q;                                                       \
-    }
-
 static const char *json_escape_str(char **dst, size_t *dst_size, const char *src,
                                    void *log_ctx)
 {



More information about the ffmpeg-cvslog mailing list