Browse code

AVOptions: add av_opt_free convenience function.

Anton Khirnov authored on 2011/06/05 20:17:26
Showing 4 changed files
... ...
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h
17
+  Add av_opt_free convenience function.
18
+
16 19
 2011-05-28 - 0420bd7 - lavu 51.2.0 - pixdesc.h
17 20
   Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate
18 21
   avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor.
... ...
@@ -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  2
43
+#define LIBAVUTIL_VERSION_MINOR  3
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -520,6 +520,14 @@ int av_set_options_string(void *ctx, const char *opts,
520 520
     return count;
521 521
 }
522 522
 
523
+void av_opt_free(void *obj)
524
+{
525
+    const AVOption *o = NULL;
526
+    while ((o = av_next_option(obj, o)))
527
+        if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY)
528
+            av_freep((uint8_t *)obj + o->offset);
529
+}
530
+
523 531
 #ifdef TEST
524 532
 
525 533
 #undef printf
... ...
@@ -176,4 +176,9 @@ void av_opt_set_defaults2(void *s, int mask, int flags);
176 176
 int av_set_options_string(void *ctx, const char *opts,
177 177
                           const char *key_val_sep, const char *pairs_sep);
178 178
 
179
+/**
180
+ * Free all string and binary options in obj.
181
+ */
182
+void av_opt_free(void *obj);
183
+
179 184
 #endif /* AVUTIL_OPT_H */