From: Paul Eggert Date: Tue, 19 Oct 2021 23:31:32 +0000 (-0700) Subject: xalloc: new function xinmalloc X-Git-Tag: v1.0~2568 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=107c945430f8479c98dbfcc2b6947fb22fc7a4b5;p=gnulib.git xalloc: new function xinmalloc * lib/xmalloc.c (xinmalloc): New function, which is like xnmalloc but for idx_t instead of size_t. --- diff --git a/ChangeLog b/ChangeLog index a017453dc7..2f19e30a2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-10-19 Paul Eggert + + xalloc: new function xinmalloc + * lib/xmalloc.c (xinmalloc): New function, which is like + xnmalloc but for idx_t instead of size_t. + 2021-10-18 Paul Eggert regex: fix buffer read overrrun diff --git a/lib/xalloc.h b/lib/xalloc.h index ee07113fed..7f2c3fb8aa 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -60,6 +60,9 @@ void *xmalloc (size_t s) void *ximalloc (idx_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; +void *xinmalloc (idx_t n, idx_t s) + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE + _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)) _GL_ATTRIBUTE_RETURNS_NONNULL; void *xzalloc (size_t s) _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL; diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 51a0832dee..d5def0bc7c 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -101,6 +101,12 @@ xnmalloc (size_t n, size_t s) return xreallocarray (NULL, n, s); } +void * +xinmalloc (idx_t n, idx_t s) +{ + return xireallocarray (NULL, n, s); +} + /* If P is null, allocate a block of at least *PS bytes; otherwise, reallocate P so that it contains more than *PS bytes. *PS must be nonzero unless P is null. Set *PS to the new block's size, and