Before this commit, AVIOContext is to be freed with a plain av_free(), which prevents us from adding any deeper structure to it.
Unified · Split
| @@ -13,6 +13,9 @@ libavutil: 2015-08-28 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2016-xx-xx - xxxxxxx - lavf 57.11.0 - avio.h | |
| 17 | + Add avio_context_free(). From now on it must be used for freeing AVIOContext. | |
| 18 | + | |
| 16 | 19 | 2017-02-01 - xxxxxxx - lavc - avcodec.h |
| 17 | 20 | Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated |
| 18 | 21 | API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs |
| @@ -219,6 +219,14 @@ AVIOContext *avio_alloc_context( · 218 unmodified lines | ||
| 219 | 219 | int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
| 220 | 220 | int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
| 221 | 221 | |
| 222 | +/** | |
| 223 | + * Free the supplied IO context and everything associated with it. | |
| 224 | + * | |
| 225 | + * @param s Double pointer to the IO context. This function will write NULL | |
| 226 | + * into s. | |
| 227 | + */ | |
| 228 | +void avio_context_free(AVIOContext **s); | |
| 229 | + | |
| 222 | 230 | void avio_w8(AVIOContext *s, int b); |
| 223 | 231 | void avio_write(AVIOContext *s, const unsigned char *buf, int size); |
| 224 | 232 | void avio_wl64(AVIOContext *s, uint64_t val); |
| @@ -165,6 +165,11 @@ AVIOContext *avio_alloc_context( · 164 unmodified lines | ||
| 165 | 165 | return s; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | +void avio_context_free(AVIOContext **ps) | |
| 169 | +{ | |
| 170 | + av_freep(ps); | |
| 171 | +} | |
| 172 | + | |
| 168 | 173 | static void flush_buffer(AVIOContext *s) |
| 169 | 174 | { |
| 170 | 175 | if (s->buf_ptr > s->buffer) { |
| @@ -1007,7 +1012,9 @@ int avio_close(AVIOContext *s) · 836 unmodified lines | ||
| 1007 | 1012 | av_freep(&internal->protocols); |
| 1008 | 1013 | av_freep(&s->opaque); |
| 1009 | 1014 | av_freep(&s->buffer); |
| 1010 | − av_free(s); | |
| 1015 | + | |
| 1016 | + avio_context_free(&s); | |
| 1017 | + | |
| 1011 | 1018 | return ffurl_close(h); |
| 1012 | 1019 | } |
| 1013 | 1020 | |
| @@ -1186,7 +1193,9 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) · 172 unmodified lines | ||
| 1186 | 1193 | *pbuffer = d->buffer; |
| 1187 | 1194 | size = d->size; |
| 1188 | 1195 | av_free(d); |
| 1189 | − av_free(s); | |
| 1196 | + | |
| 1197 | + avio_context_free(&s); | |
| 1198 | + | |
| 1190 | 1199 | return size - padding; |
| 1191 | 1200 | } |
| 1192 | 1201 | |
| @@ -1229,6 +1238,8 @@ int ffio_close_null_buf(AVIOContext *s) · 36 unmodified lines | ||
| 1229 | 1238 | |
| 1230 | 1239 | size = d->size; |
| 1231 | 1240 | av_free(d); |
| 1232 | − av_free(s); | |
| 1241 | + | |
| 1242 | + avio_context_free(&s); | |
| 1243 | + | |
| 1233 | 1244 | return size; |
| 1234 | 1245 | } |
| @@ -30,8 +30,8 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/version.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVFORMAT_VERSION_MAJOR 57 |
| 33 | −#define LIBAVFORMAT_VERSION_MINOR 10 | |
| 34 | −#define LIBAVFORMAT_VERSION_MICRO 3 | |
| 33 | +#define LIBAVFORMAT_VERSION_MINOR 11 | |
| 34 | +#define LIBAVFORMAT_VERSION_MICRO 0 | |
| 35 | 35 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 37 | 37 | LIBAVFORMAT_VERSION_MINOR, \ |