History

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.

Anton Khirnov committed 9 years ago

Commit 99684f31 parent 435cd7b4 files · +27 −5Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avio.h +8 −0
  3. libavformat/aviobuf.c +14 −3
  4. libavformat/version.h +2 −2
doc/APIchanges+3−0
@@ -13,6 +13,9 @@ libavutil: 2015-08-28 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
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+
1619 2017-02-01 - xxxxxxx - lavc - avcodec.h
1720 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
1821 API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
libavformat/avio.h+8−0
@@ -219,6 +219,14 @@ AVIOContext *avio_alloc_context( · 218 unmodified lines
219219 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
220220 int64_t (*seek)(void *opaque, int64_t offset, int whence));
221221
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+
222230 void avio_w8(AVIOContext *s, int b);
223231 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
224232 void avio_wl64(AVIOContext *s, uint64_t val);
libavformat/aviobuf.c+14−3
@@ -165,6 +165,11 @@ AVIOContext *avio_alloc_context( · 164 unmodified lines
165165 return s;
166166 }
167167
168+void avio_context_free(AVIOContext **ps)
169+{
170+ av_freep(ps);
171+}
172+
168173 static void flush_buffer(AVIOContext *s)
169174 {
170175 if (s->buf_ptr > s->buffer) {
@@ -1007,7 +1012,9 @@ int avio_close(AVIOContext *s) · 836 unmodified lines
10071012 av_freep(&internal->protocols);
10081013 av_freep(&s->opaque);
10091014 av_freep(&s->buffer);
1010− av_free(s);
1015+
1016+ avio_context_free(&s);
1017+
10111018 return ffurl_close(h);
10121019 }
10131020
@@ -1186,7 +1193,9 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) · 172 unmodified lines
11861193 *pbuffer = d->buffer;
11871194 size = d->size;
11881195 av_free(d);
1189− av_free(s);
1196+
1197+ avio_context_free(&s);
1198+
11901199 return size - padding;
11911200 }
11921201
@@ -1229,6 +1238,8 @@ int ffio_close_null_buf(AVIOContext *s) · 36 unmodified lines
12291238
12301239 size = d->size;
12311240 av_free(d);
1232− av_free(s);
1241+
1242+ avio_context_free(&s);
1243+
12331244 return size;
12341245 }
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
3030 #include "libavutil/version.h"
3131
3232 #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
3535
3636 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3737 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t