diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-02-26 21:20:00 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-26 21:20:00 +0100 |
commit | aa484f356110d9118c44389fe8f03ee7b25a7746 (patch) | |
tree | 5a284768496b9adbb15cb6d6ca89fac547138ec7 /src/basic/alloc-util.h | |
parent | f2e3f3695052ce59d119758d02bec9b1021731bd (diff) | |
download | systemd-aa484f356110d9118c44389fe8f03ee7b25a7746.tar.gz |
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.
Diffstat (limited to 'src/basic/alloc-util.h')
-rw-r--r-- | src/basic/alloc-util.h | 4 |
1 files changed, 3 insertions, 1 deletions
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)) |