diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-25 00:32:57 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-25 00:33:09 +0100 |
commit | 6e9bbaca6c6739e6524809d3e786ce1e10ad518b (patch) | |
tree | 362f71cf647b709b542e95a2a047e0b26cad5009 | |
parent | 79052cd4ce4a8857cd1088cc69ba59506dfb1b81 (diff) | |
parent | 8a273a746061a112e5e35066a8fd8e146d821a62 (diff) | |
download | ffmpeg-6e9bbaca6c6739e6524809d3e786ce1e10ad518b.tar.gz |
Merge commit '8a273a746061a112e5e35066a8fd8e146d821a62'
* commit '8a273a746061a112e5e35066a8fd8e146d821a62':
avio: Add an internal utility function for freeing dynamic buffers
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/avio_internal.h | 7 | ||||
-rw-r--r-- | libavformat/aviobuf.c | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 5864048811..f728535495 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -150,4 +150,11 @@ int ffio_open_null_buf(AVIOContext **s); */ int ffio_close_null_buf(AVIOContext *s); +/** + * Free a dynamic buffer. + * + * @param s a pointer to an IO context opened by avio_open_dyn_buf() + */ +void ffio_free_dyn_buf(AVIOContext **s); + #endif /* AVFORMAT_AVIO_INTERNAL_H */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3d77a7ff25..377d96686d 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1117,6 +1117,16 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) return size - padding; } +void ffio_free_dyn_buf(AVIOContext **s) +{ + uint8_t *tmp; + if (!*s) + return; + avio_close_dyn_buf(*s, &tmp); + av_free(tmp); + *s = NULL; +} + static int null_buf_write(void *opaque, uint8_t *buf, int buf_size) { DynBuffer *d = opaque; |