... | ... |
@@ -91,6 +91,32 @@ size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) |
91 | 91 |
return len; |
92 | 92 |
} |
93 | 93 |
|
94 |
+char *av_asprintf(const char *fmt, ...) |
|
95 |
+{ |
|
96 |
+ char *p = NULL; |
|
97 |
+ va_list va; |
|
98 |
+ int len; |
|
99 |
+ |
|
100 |
+ va_start(va, fmt); |
|
101 |
+ len = vsnprintf(NULL, 0, fmt, va); |
|
102 |
+ va_end(va); |
|
103 |
+ if (len < 0) |
|
104 |
+ goto end; |
|
105 |
+ |
|
106 |
+ p = av_malloc(len + 1); |
|
107 |
+ if (!p) |
|
108 |
+ goto end; |
|
109 |
+ |
|
110 |
+ va_start(va, fmt); |
|
111 |
+ len = vsnprintf(p, len + 1, fmt, va); |
|
112 |
+ va_end(va); |
|
113 |
+ if (len < 0) |
|
114 |
+ av_freep(&p); |
|
115 |
+ |
|
116 |
+end: |
|
117 |
+ return p; |
|
118 |
+} |
|
119 |
+ |
|
94 | 120 |
char *av_d2str(double d) |
95 | 121 |
{ |
96 | 122 |
char *str= av_malloc(16); |
... | ... |
@@ -111,6 +111,16 @@ size_t av_strlcat(char *dst, const char *src, size_t size); |
111 | 111 |
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); |
112 | 112 |
|
113 | 113 |
/** |
114 |
+ * Print arguments following specified format into a large enough auto |
|
115 |
+ * allocated buffer. It is similar to GNU asprintf(). |
|
116 |
+ * @param fmt printf-compatible format string, specifying how the |
|
117 |
+ * following parameters are used. |
|
118 |
+ * @return the allocated string |
|
119 |
+ * @note You have to free the string yourself with av_free(). |
|
120 |
+ */ |
|
121 |
+char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); |
|
122 |
+ |
|
123 |
+/** |
|
114 | 124 |
* Convert a number to a av_malloced string. |
115 | 125 |
*/ |
116 | 126 |
char *av_d2str(double d); |
... | ... |
@@ -40,7 +40,7 @@ |
40 | 40 |
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
41 | 41 |
|
42 | 42 |
#define LIBAVUTIL_VERSION_MAJOR 51 |
43 |
-#define LIBAVUTIL_VERSION_MINOR 15 |
|
43 |
+#define LIBAVUTIL_VERSION_MINOR 16 |
|
44 | 44 |
#define LIBAVUTIL_VERSION_MICRO 0 |
45 | 45 |
|
46 | 46 |
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |