Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-05-14 21:54:36 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-05-15 20:08:32 +0400
commitf8196759b45d658fd67064c83e18da1cc871e205 (patch)
tree11709d3b4d3495eeea939856dc6676aa70cee339 /libavutil/fifo.c
parentb9777797be2f4a49894e682ad83f680b563e23d5 (diff)
fifo: add av_fifo_grow()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r--libavutil/fifo.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index d1d9ba8003..47328c4585 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -79,6 +79,19 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
return 0;
}
+int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
+{
+ unsigned int old_size = f->end - f->buffer;
+ if(size + (unsigned)av_fifo_size(f) < size)
+ return AVERROR(EINVAL);
+
+ size += av_fifo_size(f);
+
+ if (old_size < size)
+ return av_fifo_realloc2(f, FFMAX(size, 2*size));
+ return 0;
+}
+
// src must NOT be const as it can be a context for func that may need updating (like a pointer or byte counter)
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
{