[FFmpeg-devel] [PATCH 1/2] avio_alloc_context: Allocate a buffer if NULL is passed
wm4
nfxjfg at googlemail.com
Thu May 22 09:17:28 CEST 2014
On Wed, 21 May 2014 22:18:52 +0200
Michael Niedermayer <michaelni at gmx.at> wrote:
> Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> ---
> libavformat/aviobuf.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 738459e..e60574d 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -119,6 +119,15 @@ AVIOContext *avio_alloc_context(
> AVIOContext *s = av_mallocz(sizeof(AVIOContext));
> if (!s)
> return NULL;
> + if (!buffer && !buffer_size)
> + buffer_size = IO_BUFFER_SIZE;
> + if (!buffer) {
> + buffer = av_malloc(buffer_size);
> + if (!buffer) {
> + av_free(s);
> + return NULL;
> + }
> + }
> ffio_init_context(s, buffer, buffer_size, write_flag, opaque,
> read_packet, write_packet, seek);
> return s;
Is the buffer actually free'd? I faintly remember that you have to do
this manually with custom AVIO contexts.
More information about the ffmpeg-devel
mailing list