From aa484f356110d9118c44389fe8f03ee7b25a7746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 26 Feb 2018 21:20:00 +0100 Subject: tree-wide: use reallocarray instead of our home-grown realloc_multiply (#8279) There isn't much difference, but in general we prefer to use the standard functions. glibc provides reallocarray since version 2.26. I moved explicit_bzero is configure test to the bottom, so that the two stdlib functions are at the bottom. --- src/basic/alloc-util.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/basic/alloc-util.h') diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h index 02dee37d36..ec7808c1f7 100644 --- a/src/basic/alloc-util.h +++ b/src/basic/alloc-util.h @@ -74,12 +74,14 @@ _malloc_ _alloc_(1, 2) static inline void *malloc_multiply(size_t size, size_t return malloc(size * need); } -_alloc_(2, 3) static inline void *realloc_multiply(void *p, size_t size, size_t need) { +#if !HAVE_REALLOCARRAY +_alloc_(2, 3) static inline void *reallocarray(void *p, size_t need, size_t size) { if (size_multiply_overflow(size, need)) return NULL; return realloc(p, size * need); } +#endif _alloc_(2, 3) static inline void *memdup_multiply(const void *p, size_t size, size_t need) { if (size_multiply_overflow(size, need)) -- cgit v1.2.1