]> Savannah Git Hosting - gnulib.git/commitdiff
xalloc: new function xinmalloc
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 19 Oct 2021 23:31:32 +0000 (16:31 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 19 Oct 2021 23:48:42 +0000 (16:48 -0700)
* lib/xmalloc.c (xinmalloc): New function, which is like
xnmalloc but for idx_t instead of size_t.

ChangeLog
lib/xalloc.h
lib/xmalloc.c

index a017453dc73e6b62482b2c98f009c1edec55f229..2f19e30a2a20104f3ce8e7d9e2def121603979af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-10-19  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <eggert@cs.ucla.edu>
 
        regex: fix buffer read overrrun
index ee07113fed0f830abe81fffbdb383a811028e593..7f2c3fb8aa78211b516196c603efd4ba2dc374f8 100644 (file)
@@ -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;
index 51a0832dee1464b93c2363496bb960ae4abeaa03..d5def0bc7c549c805e863bbd58287cd3018d0368 100644 (file)
@@ -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