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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162016-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
162017-02-01 - xxxxxxx - lavc - avcodec.h192017-02-01 - xxxxxxx - lavc - avcodec.h
17 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated20 Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
18 API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs21 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
219 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),219 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
220 int64_t (*seek)(void *opaque, int64_t offset, int whence));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 */
228void avio_context_free(AVIOContext **s);
229
222void avio_w8(AVIOContext *s, int b);230void avio_w8(AVIOContext *s, int b);
223void avio_write(AVIOContext *s, const unsigned char *buf, int size);231void avio_write(AVIOContext *s, const unsigned char *buf, int size);
224void avio_wl64(AVIOContext *s, uint64_t val);232void avio_wl64(AVIOContext *s, uint64_t val);
libavformat/aviobuf.c+14−3
@@ -165,6 +165,11 @@ AVIOContext *avio_alloc_context( · 164 unmodified lines
165 return s;165 return s;
166}166}
167 167
168void avio_context_free(AVIOContext **ps)
169{
170 av_freep(ps);
171}
172
168static void flush_buffer(AVIOContext *s)173static void flush_buffer(AVIOContext *s)
169{174{
170 if (s->buf_ptr > s->buffer) {175 if (s->buf_ptr > s->buffer) {
@@ -1007,7 +1012,9 @@ int avio_close(AVIOContext *s) · 836 unmodified lines
1007 av_freep(&internal->protocols);1012 av_freep(&internal->protocols);
1008 av_freep(&s->opaque);1013 av_freep(&s->opaque);
1009 av_freep(&s->buffer);1014 av_freep(&s->buffer);
1010 av_free(s);1015
1016 avio_context_free(&s);
1017
1011 return ffurl_close(h);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 *pbuffer = d->buffer;1193 *pbuffer = d->buffer;
1187 size = d->size;1194 size = d->size;
1188 av_free(d);1195 av_free(d);
1189 av_free(s);1196
1197 avio_context_free(&s);
1198
1190 return size - padding;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 size = d->size;1239 size = d->size;
1231 av_free(d);1240 av_free(d);
1232 av_free(s);1241
1242 avio_context_free(&s);
1243
1233 return size;1244 return size;
1234}1245}
libavformat/version.h+2−2
@@ -30,8 +30,8 @@ · 29 unmodified lines
30#include "libavutil/version.h"30#include "libavutil/version.h"
31 31
32#define LIBAVFORMAT_VERSION_MAJOR 5732#define LIBAVFORMAT_VERSION_MAJOR 57
33#define LIBAVFORMAT_VERSION_MINOR 1033#define LIBAVFORMAT_VERSION_MINOR 11
34#define LIBAVFORMAT_VERSION_MICRO 334#define LIBAVFORMAT_VERSION_MICRO 0
35 35
36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \36#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
37 LIBAVFORMAT_VERSION_MINOR, \37 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