[FFmpeg-cvslog] avutil/mem: make ff_fast_malloc() internal to mem.c

James Almer git at videolan.org
Thu May 27 16:31:40 EEST 2021


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun May 23 11:24:17 2021 -0300| [786be70e28fe739b8e49893fa13ae4652a68d1ea] | committer: James Almer

avutil/mem: make ff_fast_malloc() internal to mem.c

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=786be70e28fe739b8e49893fa13ae4652a68d1ea
---

 libavutil/mem.c          | 23 +++++++++++++++++++++--
 libavutil/mem_internal.h | 18 ------------------
 2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/libavutil/mem.c b/libavutil/mem.c
index c12c24aa90..3c014f3f68 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -510,12 +510,31 @@ 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 */



More information about the ffmpeg-cvslog mailing list