libavutil/fifo: Fix fifo grow step
authorJan Sebechlebsky <sebechlebskyjan@gmail.com>
Fri, 3 Jun 2016 12:04:00 +0000 (14:04 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 3 Jun 2016 12:49:56 +0000 (14:49 +0200)
Fifo was reallocating always to twice of the requested size.
This fixes it to reallocate to requested size, or twice of the
original size - whichever is greater.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/fifo.c

index 986729a..1060aed 100644 (file)
@@ -113,7 +113,7 @@ int av_fifo_grow(AVFifoBuffer *f, unsigned int size)
     size += av_fifo_size(f);
 
     if (old_size < size)
-        return av_fifo_realloc2(f, FFMAX(size, 2*size));
+        return av_fifo_realloc2(f, FFMAX(size, 2*old_size));
     return 0;
 }