Before this commit, AVIOContext is to be freed with a plain av_free(),
which prevents us from adding any deeper structure to it.
(cherry picked from commit 99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d)
Signed-off-by: James Almer <jamrial@gmail.com>
| ... | ... |
@@ -15,6 +15,9 @@ libavutil: 2015-08-28 |
| 15 | 15 |
|
| 16 | 16 |
API changes, most recent first: |
| 17 | 17 |
|
| 18 |
+2017-09-01 - xxxxxxx - lavf 57.80.100 / 57.11.0 - avio.h |
|
| 19 |
+ Add avio_context_free(). From now on it must be used for freeing AVIOContext. |
|
| 20 |
+ |
|
| 18 | 21 |
2017-08-08 - xxxxxxx - lavu 55.74.100 - pixdesc.h |
| 19 | 22 |
Add AV_PIX_FMT_FLAG_FLOAT pixel format flag. |
| 20 | 23 |
|
| ... | ... |
@@ -467,6 +467,14 @@ AVIOContext *avio_alloc_context( |
| 467 | 467 |
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), |
| 468 | 468 |
int64_t (*seek)(void *opaque, int64_t offset, int whence)); |
| 469 | 469 |
|
| 470 |
+/** |
|
| 471 |
+ * Free the supplied IO context and everything associated with it. |
|
| 472 |
+ * |
|
| 473 |
+ * @param s Double pointer to the IO context. This function will write NULL |
|
| 474 |
+ * into s. |
|
| 475 |
+ */ |
|
| 476 |
+void avio_context_free(AVIOContext **s); |
|
| 477 |
+ |
|
| 470 | 478 |
void avio_w8(AVIOContext *s, int b); |
| 471 | 479 |
void avio_write(AVIOContext *s, const unsigned char *buf, int size); |
| 472 | 480 |
void avio_wl64(AVIOContext *s, uint64_t val); |
| ... | ... |
@@ -143,6 +143,11 @@ AVIOContext *avio_alloc_context( |
| 143 | 143 |
return s; |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
+void avio_context_free(AVIOContext **ps) |
|
| 147 |
+{
|
|
| 148 |
+ av_freep(ps); |
|
| 149 |
+} |
|
| 150 |
+ |
|
| 146 | 151 |
static void writeout(AVIOContext *s, const uint8_t *data, int len) |
| 147 | 152 |
{
|
| 148 | 153 |
if (!s->error) {
|
| ... | ... |
@@ -1123,7 +1128,9 @@ int avio_close(AVIOContext *s) |
| 1123 | 1123 |
else |
| 1124 | 1124 |
av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count); |
| 1125 | 1125 |
av_opt_free(s); |
| 1126 |
- av_free(s); |
|
| 1126 |
+ |
|
| 1127 |
+ avio_context_free(&s); |
|
| 1128 |
+ |
|
| 1127 | 1129 |
return ffurl_close(h); |
| 1128 | 1130 |
} |
| 1129 | 1131 |
|
| ... | ... |
@@ -1356,7 +1363,9 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) |
| 1356 | 1356 |
*pbuffer = d->buffer; |
| 1357 | 1357 |
size = d->size; |
| 1358 | 1358 |
av_free(d); |
| 1359 |
- av_free(s); |
|
| 1359 |
+ |
|
| 1360 |
+ avio_context_free(&s); |
|
| 1361 |
+ |
|
| 1360 | 1362 |
return size - padding; |
| 1361 | 1363 |
} |
| 1362 | 1364 |
|
| ... | ... |
@@ -1399,6 +1408,8 @@ int ffio_close_null_buf(AVIOContext *s) |
| 1399 | 1399 |
|
| 1400 | 1400 |
size = d->size; |
| 1401 | 1401 |
av_free(d); |
| 1402 |
- av_free(s); |
|
| 1402 |
+ |
|
| 1403 |
+ avio_context_free(&s); |
|
| 1404 |
+ |
|
| 1403 | 1405 |
return size; |
| 1404 | 1406 |
} |
| ... | ... |
@@ -32,7 +32,7 @@ |
| 32 | 32 |
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) |
| 33 | 33 |
// Also please add any ticket numbers that you believe might be affected here |
| 34 | 34 |
#define LIBAVFORMAT_VERSION_MAJOR 57 |
| 35 |
-#define LIBAVFORMAT_VERSION_MINOR 79 |
|
| 35 |
+#define LIBAVFORMAT_VERSION_MINOR 80 |
|
| 36 | 36 |
#define LIBAVFORMAT_VERSION_MICRO 100 |
| 37 | 37 |
|
| 38 | 38 |
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |