diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-09 09:26:32 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-03-09 09:26:32 +0000 |
commit | 32b936d0c368db467be1c0501b36d9a995545675 (patch) | |
tree | b97b05a2f537c404ac25d60275aae2b53b0ca44a /libavutil/fifo.c | |
parent | aa033b1ed76269f56e602a42b6fdd8dfe7cb4768 (diff) | |
download | ffmpeg-32b936d0c368db467be1c0501b36d9a995545675.tar.gz |
Add av_fifo_reset function to completely reset fifo state, which makes
it easier to reuse the fifo.
Originally committed as revision 17901 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavutil/fifo.c')
-rw-r--r-- | libavutil/fifo.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libavutil/fifo.c b/libavutil/fifo.c index f36dfeea6e..9a9a139f3b 100644 --- a/libavutil/fifo.c +++ b/libavutil/fifo.c @@ -27,9 +27,9 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size) AVFifoBuffer *f= av_mallocz(sizeof(AVFifoBuffer)); if(!f) return NULL; - f->wptr = f->rptr = f->buffer = av_malloc(size); f->end = f->buffer + size; + av_fifo_reset(f); if (!f->buffer) av_freep(&f); return f; @@ -43,6 +43,12 @@ void av_fifo_free(AVFifoBuffer *f) } } +void av_fifo_reset(AVFifoBuffer *f) +{ + f->wptr = f->rptr = f->buffer; + f->wndx = f->rndx = 0; +} + int av_fifo_size(AVFifoBuffer *f) { return (uint32_t)(f->wndx - f->rndx); |