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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-02-26 21:20:00 +01:00
committed by Lennart Poettering
parent f2e3f36950
commit aa484f3561
9 changed files with 16 additions and 13 deletions
+3 -1
View File
@@ -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))