diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-20 00:22:48 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-20 00:22:51 +0200 |
commit | 6218831844fa5a517eda857adee7960aa0a9c033 (patch) | |
tree | ef558092b7894d7f51b14af46203f17ddea49bb6 /libavutil/fifo.c | |
parent | ab6228316a595ecc1ee462a34a4f19e1ffeb9062 (diff) | |
parent | b9419b58826effc3d9afabd1a2e50d66391fbdbf (diff) | |
download | ffmpeg-6218831844fa5a517eda857adee7960aa0a9c033.tar.gz |
Merge remote-tracking branch 'lukaszmluki/master'
* lukaszmluki/master:
lavf/ftp: favour EPSV over PASV command
lavf/audiointerleave: return more meaningful error codes
lavf/audiointerleave: check for allocation failure
lavf/audiointerleave: use av_fifo_alloc_array
lavf/dvenc: use av_fifo_alloc_array
lavc/flac_parser: use av_fifo_alloc_array
lavc/frame_thread_encoder: use av_fifo_alloc_array
lavfi/vf_fps: use av_fifo_alloc_array
lavfi/buffersink: use av_fifo_alloc_array
ffmpeg: use av_fifo_alloc_array
lavd/jack_audio: use av_fifo_alloc_array
lavu/fifo: add av_fifo_alloc_array function
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r-- | libavutil/fifo.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c index 09ffa4fd26..77391ee7f2 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -24,19 +24,34 @@ #include "common.h" #include "fifo.h" -AVFifoBuffer *av_fifo_alloc(unsigned int size) +static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size) { - AVFifoBuffer *f = av_mallocz(sizeof(AVFifoBuffer)); - if (!f) + AVFifoBuffer *f; + if (!buffer) + return NULL; + f = av_mallocz(sizeof(AVFifoBuffer)); + if (!f) { + av_free(buffer); return NULL; - f->buffer = av_malloc(size); + } + f->buffer = buffer; f->end = f->buffer + size; av_fifo_reset(f); - if (!f->buffer) - av_freep(&f); return f; } +AVFifoBuffer *av_fifo_alloc(unsigned int size) +{ + void *buffer = av_malloc(size); + return fifo_alloc_common(buffer, size); +} + +AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size) +{ + void *buffer = av_malloc_array(nmemb, size); + return fifo_alloc_common(buffer, nmemb * size); +} + void av_fifo_free(AVFifoBuffer *f) { if (f) { |