]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
regex: port to non-GNU malloc
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 27 Apr 2026 21:55:39 +0000 (14:55 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 27 Apr 2026 22:01:18 +0000 (15:01 -0700)
This is for Gawk, which does not use malloc-gnu.
* lib/regex.c (_GL_USE_STDLIB_ALLOC) [!_LIBC]:
Define, since this module is now safe for AIX-like malloc.
* lib/regex_internal.h (re_malloc) [!_LIBC && !HAVE_MALLOC_0_NONNULL]:
Don’t pass 0 to malloc.

ChangeLog
lib/regex.c
lib/regex_internal.h

index 95d69e6611ba2033579d98fe0a52a9af5ccf05df..e50481b985540f19529f20742e50311b7ea599f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2026-04-27  Paul Eggert  <eggert@cs.ucla.edu>
 
+       regex: port to non-GNU malloc
+       This is for Gawk, which does not use malloc-gnu.
+       * lib/regex.c (_GL_USE_STDLIB_ALLOC) [!_LIBC]:
+       Define, since this module is now safe for AIX-like malloc.
+       * lib/regex_internal.h (re_malloc) [!_LIBC && !HAVE_MALLOC_0_NONNULL]:
+       Don’t pass 0 to malloc.
+
        regex: SSIZE_MAX porting
        * lib/regex_internal.h (IDX_MAX) [_REGEX_LARGE_OFFSETS]:
        Port to non-POSIX platforms where limits.h does not define SSIZE_MAX.
index f9f333d237dfd4cbc4e5a9986ad07dad2216820f..d0c7af90186999b38336341af3fd79c33cab1391 100644 (file)
@@ -20,6 +20,7 @@
 #define __STDC_WANT_IEC_60559_BFP_EXT__
 
 #ifndef _LIBC
+# define _GL_USE_STDLIB_ALLOC 1
 # include <libc-config.h>
 
 # if __GNUC_PREREQ (4, 6)
index 6e526a6f3886d7c22d4edb249880f48a193f92fe..c4e05ec72d9ca5e98063309373dc80491d112a90 100644 (file)
@@ -448,7 +448,11 @@ typedef struct re_dfa_t re_dfa_t;
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
+#if defined _LIBC || HAVE_MALLOC_0_NONNULL
+# define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
+#else
+# define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t) + !(n)))
+#endif
 #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
 #define re_free(p) free (p)