aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/aviobuf.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2017-01-13 11:53:51 +0100
committerAnton Khirnov <anton@khirnov.net>2017-02-11 11:37:44 +0100
commit99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d (patch)
treefe2ddc08dc5fb6bc915197d44319e845ef80452d /libavformat/aviobuf.c
parent435cd7bc99671bf561193421a50ac6e9d63c4266 (diff)
downloadffmpeg-99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d.tar.gz
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.
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 6d83a9661b..31476d3f6d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -165,6 +165,11 @@ AVIOContext *avio_alloc_context(
return s;
}
+void avio_context_free(AVIOContext **ps)
+{
+ av_freep(ps);
+}
+
static void flush_buffer(AVIOContext *s)
{
if (s->buf_ptr > s->buffer) {
@@ -1007,7 +1012,9 @@ int avio_close(AVIOContext *s)
av_freep(&internal->protocols);
av_freep(&s->opaque);
av_freep(&s->buffer);
- av_free(s);
+
+ avio_context_free(&s);
+
return ffurl_close(h);
}
@@ -1186,7 +1193,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;
}
@@ -1229,6 +1238,8 @@ int ffio_close_null_buf(AVIOContext *s)
size = d->size;
av_free(d);
- av_free(s);
+
+ avio_context_free(&s);
+
return size;
}