summaryrefslogtreecommitdiff
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2017-08-27 13:26:58 -0300
committerJames Almer <jamrial@gmail.com>2017-09-01 01:51:15 -0300
commitb12e4d3bb8df994f042ff1216fb8de2b967aab9e (patch)
tree9d2572b4666edf949b82ffacc4f14103366e3883 /libavformat/aviobuf.c
parent837580f458f2ccbbd6e82d3c7591916deb81ef02 (diff)
avio: add a destructor for AVIOContext
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>
Diffstat (limited to 'libavformat/aviobuf.c')
-rw-r--r--libavformat/aviobuf.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index ec21fc7d38..716c42eda9 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -143,6 +143,11 @@ AVIOContext *avio_alloc_context(
return s;
}
+void avio_context_free(AVIOContext **ps)
+{
+ av_freep(ps);
+}
+
static void writeout(AVIOContext *s, const uint8_t *data, int len)
{
if (!s->error) {
@@ -1123,7 +1128,9 @@ int avio_close(AVIOContext *s)
else
av_log(s, AV_LOG_DEBUG, "Statistics: %"PRId64" bytes read, %d seeks\n", s->bytes_read, s->seek_count);
av_opt_free(s);
- av_free(s);
+
+ avio_context_free(&s);
+
return ffurl_close(h);
}
@@ -1356,7 +1363,9 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
*pbuffer = d->buffer;
size = d->size;
av_free(d);
- av_free(s);
+
+ avio_context_free(&s);
+
return size - padding;
}
@@ -1399,6 +1408,8 @@ int ffio_close_null_buf(AVIOContext *s)
size = d->size;
av_free(d);
- av_free(s);
+
+ avio_context_free(&s);
+
return size;
}