changeset 511:5accd0bccc76 libavutil

Ensure that one can store X bytes in a fifo of size X. Fixed issue417.
author michael
date Sun, 25 May 2008 23:04:09 +0000
parents b7593ce78422
children 3ac9085839f0
files fifo.c fifo.h
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;
 
--- 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.