From 969abd302211262562df93ae5412ee319aae69e6 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 3 Mar 2020 15:41:39 +0100 Subject: core: New function gpgrt_reallocarray. * src/init.c (_gpgrt_reallocarray): New. * src/visibility.c (gpgrt_reallocarray): New. * src/gpg-error.vers, src/gpg-error.def.in: Add new function. * src/gpg-error.h.in: Add new interface. * tests/t-malloc.c: New. * tests/Makefile.am (TESTS): Add new test. -- Note that this function is different from the glibc function because it has an extra parameter which allows to clear the new elements. A realloc after a calloc with forgotten memset after it is a common source of error, thus we introduce this slightly different function. Signed-off-by: Werner Koch --- src/visibility.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/visibility.c') diff --git a/src/visibility.c b/src/visibility.c index ea55d54..2e6aed7 100644 --- a/src/visibility.c +++ b/src/visibility.c @@ -763,6 +763,12 @@ gpgrt_realloc (void *a, size_t n) return _gpgrt_realloc (a, n); } +void * +gpgrt_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size) +{ + return _gpgrt_reallocarray (a, oldnmemb, nmemb, size); +} + void * gpgrt_malloc (size_t n) { -- cgit v1.2.3