diff mbox series

[FFmpeg-devel,4/7] lavu/fifo: simplify av_fifo_alloc()

Message ID 20211231105307.30946-4-anton@khirnov.net
State Accepted
Commit 5010c481d1a4bbd52655c43f5d7627d4c0a90f72
Headers show
Series [FFmpeg-devel,1/7] lavc/flac_parser: use a custom FIFO implementation | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Anton Khirnov Dec. 31, 2021, 10:53 a.m. UTC
Turn it into a wrapper around av_fifo_alloc_array().
---
 libavutil/fifo.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 1060aedf13..5eee18a8c8 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -24,9 +24,10 @@ 
 #include "common.h"
 #include "fifo.h"
 
-static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size)
+AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size)
 {
     AVFifoBuffer *f;
+    void *buffer = av_malloc_array(nmemb, size);
     if (!buffer)
         return NULL;
     f = av_mallocz(sizeof(AVFifoBuffer));
@@ -35,21 +36,14 @@  static AVFifoBuffer *fifo_alloc_common(void *buffer, size_t size)
         return NULL;
     }
     f->buffer = buffer;
-    f->end    = f->buffer + size;
+    f->end    = f->buffer + nmemb * size;
     av_fifo_reset(f);
     return f;
 }
 
 AVFifoBuffer *av_fifo_alloc(unsigned int size)
 {
-    void *buffer = av_malloc(size);
-    return fifo_alloc_common(buffer, size);
-}
-
-AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size)
-{
-    void *buffer = av_malloc_array(nmemb, size);
-    return fifo_alloc_common(buffer, nmemb * size);
+    return av_fifo_alloc_array(size, 1);
 }
 
 void av_fifo_free(AVFifoBuffer *f)