summaryrefslogtreecommitdiff
path: root/libavutil/fifo.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2007-01-17 20:05:31 +0000
committerMichael Niedermayer <michaelni@gmx.at>2007-01-17 20:05:31 +0000
commit96e39edc59ca87793c6c196af7d02778e644ad62 (patch)
tree74af58b97690e484ba9df9db44d27bdeb8ed4fa1 /libavutil/fifo.c
parent765d4f3b4a49e974c7f122068ae0a10109423048 (diff)
simplify av_fifo_realloc()
Originally committed as revision 7571 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r--libavutil/fifo.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 0f530849df..48cd777c62 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -60,18 +60,14 @@ void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
unsigned int old_size= f->end - f->buffer;
if(old_size < new_size){
- uint8_t *old= f->buffer;
+ int len= av_fifo_size(f);
+ AVFifoBuffer f2;
- f->buffer= av_realloc(f->buffer, new_size);
-
- f->rptr += f->buffer - old;
- f->wptr += f->buffer - old;
-
- if(f->wptr < f->rptr){
- memmove(f->rptr + new_size - old_size, f->rptr, f->buffer + old_size - f->rptr);
- f->rptr += new_size - old_size;
- }
- f->end= f->buffer + new_size;
+ av_fifo_init(&f2, new_size);
+ av_fifo_read(f, f2.buffer, len);
+ f2.wptr += len;
+ av_free(f->buffer);
+ *f= f2;
}
}