diff mbox series

[FFmpeg-devel,12/12] avutil/mem: Deprecate av_mallocz_array()

Message ID AM7PR03MB6660E1F8A57B76DF6578148B8FDB9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,01/10] avcodec/mpegvideo: Move startcodes to mpeg12.h | 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 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 15, 2021, 12:57 a.m. UTC
It does the same as av_calloc(), so one of them should be removed.
Given that av_calloc() has the shorter name, it is retained.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavutil/mem.c     |  2 ++
 libavutil/mem.h     | 11 ++++++-----
 libavutil/version.h |  3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)

Comments

Paul B Mahol Sept. 15, 2021, 7:12 a.m. UTC | #1
lgtm
diff mbox series

Patch

diff --git a/libavutil/mem.c b/libavutil/mem.c
index dcc75945d4..194d880587 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -211,6 +211,7 @@  void *av_malloc_array(size_t nmemb, size_t size)
     return av_malloc(result);
 }
 
+#if FF_API_AV_MALLOCZ_ARRAY
 void *av_mallocz_array(size_t nmemb, size_t size)
 {
     size_t result;
@@ -218,6 +219,7 @@  void *av_mallocz_array(size_t nmemb, size_t size)
         return NULL;
     return av_mallocz(result);
 }
+#endif
 
 void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
 {
diff --git a/libavutil/mem.h b/libavutil/mem.h
index c7f8867a13..b9fe80738c 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -237,14 +237,15 @@  av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size);
  * @see av_mallocz()
  * @see av_malloc_array()
  */
-av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size);
+void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2);
 
+#if FF_API_AV_MALLOCZ_ARRAY
 /**
- * Equivalent of av_mallocz_array().
- *
- * Created for symmetry with the calloc() C function.
+ * @deprecated use av_calloc()
  */
-void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
+attribute_deprecated
+void *av_mallocz_array(size_t nmemb, size_t size) av_malloc_attrib av_alloc_size(1, 2);
+#endif
 
 /**
  * Allocate, reallocate, or free a block of memory.
diff --git a/libavutil/version.h b/libavutil/version.h
index f220e192c8..3261f1eea6 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -114,6 +114,9 @@ 
 #ifndef FF_API_COLORSPACE_NAME
 #define FF_API_COLORSPACE_NAME          (LIBAVUTIL_VERSION_MAJOR < 58)
 #endif
+#ifndef FF_API_AV_MALLOCZ_ARRAY
+#define FF_API_AV_MALLOCZ_ARRAY         (LIBAVUTIL_VERSION_MAJOR < 58)
+#endif
 
 /**
  * @}