From 04b0f0e371ff81b682274b574fb465ba4395c09f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 30 Mar 2017 17:02:39 +0200 Subject: [PATCH] mem: uninline av_malloc(z)_array() Inlining public functions hardcodes their implementation into the ABI, so it should be avoided unless there is a very good reason for it. No such reason exists in this case. --- libavutil/mem.c | 14 ++++++++++++++ libavutil/mem.h | 14 ++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libavutil/mem.c b/libavutil/mem.c index 0f506d3604..fd0ffd988c 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -138,6 +138,20 @@ int av_reallocp(void *ptr, size_t size) return 0; } +void *av_malloc_array(size_t nmemb, size_t size) +{ + if (!size || nmemb >= INT_MAX / size) + return NULL; + return av_malloc(nmemb * size); +} + +void *av_mallocz_array(size_t nmemb, size_t size) +{ + if (!size || nmemb >= INT_MAX / size) + return NULL; + return av_mallocz(nmemb * size); +} + void *av_realloc_array(void *ptr, size_t nmemb, size_t size) { if (!size || nmemb >= INT_MAX / size) diff --git a/libavutil/mem.h b/libavutil/mem.h index f3cf56c498..a03ba2f528 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -89,12 +89,7 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); * be allocated. * @see av_malloc() */ -av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) -{ - if (!size || nmemb >= INT_MAX / size) - return NULL; - return av_malloc(nmemb * size); -} +av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size); /** * Allocate or reallocate a block of memory. @@ -202,12 +197,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); * @see av_mallocz() * @see av_malloc_array() */ -av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) -{ - if (!size || nmemb >= INT_MAX / size) - return NULL; - return av_mallocz(nmemb * size); -} +av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size); /** * Duplicate the string s.