diff mbox series

[FFmpeg-devel,2/3] avutil/mem: make ff_fast_malloc() internal to mem.c

Message ID 20210523145433.5426-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avcodec/utils: don't use ff_fast_mallocz in av_fast_padded_malloc()
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer May 23, 2021, 2:54 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavutil/mem.c          | 24 ++++++++++++++++++++++--
 libavutil/mem_internal.h | 18 ------------------
 2 files changed, 22 insertions(+), 20 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/mem.c b/libavutil/mem.c
index c12c24aa90..471b49f8e7 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -510,12 +510,32 @@  void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
     return ptr;
 }
 
+
+static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
+{
+    void *val;
+
+    memcpy(&val, ptr, sizeof(val));
+    if (min_size <= *size) {
+        av_assert0(val || !min_size);
+        return;
+    }
+    min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
+    av_freep(ptr);
+    val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
+    memcpy(ptr, &val, sizeof(val));
+    if (!val)
+        min_size = 0;
+    *size = min_size;
+    return;
+}
+
 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
 {
-    ff_fast_malloc(ptr, size, min_size, 0);
+    fast_malloc(ptr, size, min_size, 0);
 }
 
 void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
 {
-    ff_fast_malloc(ptr, size, min_size, 1);
+    fast_malloc(ptr, size, min_size, 1);
 }
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
index ee2575c85f..ed846aac52 100644
--- a/libavutil/mem_internal.h
+++ b/libavutil/mem_internal.h
@@ -136,22 +136,4 @@ 
 #   define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_A(32, t, v, __VA_ARGS__,,))
 #endif
 
-static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
-{
-    void *val;
-
-    memcpy(&val, ptr, sizeof(val));
-    if (min_size <= *size) {
-        av_assert0(val || !min_size);
-        return 0;
-    }
-    min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
-    av_freep(ptr);
-    val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
-    memcpy(ptr, &val, sizeof(val));
-    if (!val)
-        min_size = 0;
-    *size = min_size;
-    return 1;
-}
 #endif /* AVUTIL_MEM_INTERNAL_H */