# HG changeset patch # User michael # Date 1211756649 0 # Node ID 5accd0bccc76323eea4cb7e49751408a19bb4f0e # Parent b7593ce7842273b48636c36d50643356f2f1dbce Ensure that one can store X bytes in a fifo of size X. Fixed issue417. diff -r b7593ce78422 -r 5accd0bccc76 fifo.c --- a/fifo.c Sun May 25 22:20:39 2008 +0000 +++ b/fifo.c Sun May 25 23:04:09 2008 +0000 @@ -22,8 +22,9 @@ #include "common.h" #include "fifo.h" -int av_fifo_init(AVFifoBuffer *f, int size) +int av_fifo_init(AVFifoBuffer *f, unsigned int size) { + size= FFMAX(size, size+1); f->wptr = f->rptr = f->buffer = av_malloc(size); f->end = f->buffer + size; @@ -56,7 +57,7 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) { unsigned int old_size= f->end - f->buffer; - if(old_size < new_size){ + if(old_size <= new_size){ int len= av_fifo_size(f); AVFifoBuffer f2; diff -r b7593ce78422 -r 5accd0bccc76 fifo.h --- a/fifo.h Sun May 25 22:20:39 2008 +0000 +++ b/fifo.h Sun May 25 23:04:09 2008 +0000 @@ -38,7 +38,7 @@ * @param size of FIFO * @return <0 for failure >=0 otherwise */ -int av_fifo_init(AVFifoBuffer *f, int size); +int av_fifo_init(AVFifoBuffer *f, unsigned int size); /** * Frees an AVFifoBuffer.