summaryrefslogtreecommitdiff
path: root/src/gpgrt-int.h
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-03-03 15:41:39 +0100
committerWerner Koch <wk@gnupg.org>2020-03-03 15:41:39 +0100
commit969abd302211262562df93ae5412ee319aae69e6 (patch)
tree37fc4be7deab2afa11c86faf76f324ad15c7302f /src/gpgrt-int.h
parent72a15bad8f27303475498ce44e34d29b4c2c4593 (diff)
downloadlibgpg-error-969abd302211262562df93ae5412ee319aae69e6.tar.gz
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 <wk@gnupg.org>
Diffstat (limited to 'src/gpgrt-int.h')
-rw-r--r--src/gpgrt-int.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
index beb55ac..cc22004 100644
--- a/src/gpgrt-int.h
+++ b/src/gpgrt-int.h
@@ -114,6 +114,7 @@ void _gpgrt_abort (void) GPGRT_ATTR_NORETURN;
void _gpgrt_set_alloc_func (void *(*f)(void *a, size_t n));
void *_gpgrt_realloc (void *a, size_t n);
+void *_gpgrt_reallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size);
void *_gpgrt_malloc (size_t n);
void *_gpgrt_calloc (size_t n, size_t m);
char *_gpgrt_strdup (const char *string);
@@ -126,6 +127,7 @@ char *_gpgrt_strconcat_core (const char *s1, va_list arg_ptr);
#define xtrymalloc(a) _gpgrt_malloc ((a))
#define xtrycalloc(a,b) _gpgrt_calloc ((a),(b))
#define xtryrealloc(a,b) _gpgrt_realloc ((a),(b))
+#define xtryreallocarray(a,b,c,d) _gpgrt_reallocarray ((a),(b),(c),(d))
#define xtrystrdup(a) _gpgrt_strdup ((a))
void _gpgrt_pre_syscall (void);