From 6fa1808cb7639f0f3745b78c4b7ce902e42b228c Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 4 Mar 2020 13:55:53 +0100 Subject: common: Add xreallocarray function. * common/miscellaneous.c (xreallocarray): New func. * common/util.h (xtryreallocarray): New macro. -- Very useful to match calloc behaviour. Signed-off-by: Werner Koch --- common/miscellaneous.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common/miscellaneous.c') diff --git a/common/miscellaneous.c b/common/miscellaneous.c index 260552828..5ede00128 100644 --- a/common/miscellaneous.c +++ b/common/miscellaneous.c @@ -117,6 +117,17 @@ xoutofcore (void) } +/* Wrapper around gpgrt_reallocarray. */ +void * +xreallocarray (void *a, size_t oldnmemb, size_t nmemb, size_t size) +{ + void *p = gpgrt_reallocarray (a, oldnmemb, nmemb, size); + if (!p) + xoutofcore (); + return p; +} + + /* A wrapper around gcry_cipher_algo_name to return the string "AES-128" instead of "AES". Given that we have an alias in libgcrypt for it, it does not harm to too much to return this other -- cgit v1.2.3