+2024-10-27 Bruno Haible <bruno@clisp.org>
+
+ realloc-gnu: Replace module with an alias to realloc-posix.
+ * tests/test-realloc-posix.c: Renamed from tests/test-realloc-gnu.c. Add
+ more tests, not yet activated.
+ * modules/realloc-posix-tests: Renamed from modules/realloc-gnu-tests.
+ Test test-realloc-posix instead of test-realloc-gnu.
+ * modules/realloc-gnu: Mark as a deprecated alias of 'realloc-posix'.
+ * lib/stdlib.in.h (realloc): Ignore GNULIB_REALLOC_GNU.
+ * modules/stdlib (Makefile.am): Don't substitute GNULIB_REALLOC_GNU,
+ REPLACE_REALLOC_FOR_REALLOC_GNU.
+ * m4/stdlib_h.m4 (gl_STDLIB_H_REQUIRE_DEFAULTS): Don't initialize
+ GNULIB_REALLOC_GNU.
+ (gl_STDLIB_H_DEFAULTS): Don't initialize
+ REPLACE_REALLOC_FOR_REALLOC_GNU.
+ * m4/realloc.m4 (gl_FUNC_REALLOC_GNU): Remove macro.
+ * m4/malloc.m4 (gl_CHECK_MALLOC_POSIX): Update comment.
+ * doc/posix-functions/realloc.texi: Remove description of module
+ 'realloc-gnu'.
+ * MODULES.html.sh (Memory management functions <stdlib.h>): Remove
+ realloc-gnu. Add realloc-posix.
+
2024-10-27 Bruno Haible <bruno@clisp.org>
doc: Add a module index.
func_module free-posix
func_module malloc-gnu
func_module memalign
- func_module realloc-gnu
+ func_module realloc-posix
func_module reallocarray
func_module pagealign_alloc
func_end_table
glibc 2.1.1--2.40, most likely glibc 2.41+ at least by default,
Android, mingw, MSVC.
@end itemize
-
-@mindex realloc-gnu
-Extension: Gnulib provides a module @samp{realloc-gnu} that substitutes a
-@code{realloc} implementation that behaves more like the current
-glibc implementation.
-It fixes these portability problems:
-
-@itemize
-@item
-@code{realloc (NULL, 0)} returns @code{NULL} on success on some platforms:
-AIX 7.3.
-
-@item
-On some platforms, @code{realloc (p, 0)} with non-null @code{p}
-might not free @code{p}, or might clobber @code{errno},
-or might not return @code{NULL}.
-@end itemize
#if @GNULIB_REALLOC_POSIX@
-# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@) \
- || (@GNULIB_REALLOC_GNU@ && @REPLACE_REALLOC_FOR_REALLOC_GNU@)
+# if (@GNULIB_REALLOC_POSIX@ && @REPLACE_REALLOC_FOR_REALLOC_POSIX@)
# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
|| _GL_USE_STDLIB_ALLOC)
# undef realloc
# malloc.m4
-# serial 34
+# serial 35
dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl some systems go to their knees when you do that. So assume that
dnl all Unix implementations of the function set errno on failure,
dnl except on those platforms where we have seen 'test-malloc-gnu',
- dnl 'test-realloc-gnu', 'test-calloc-gnu' fail.
+ dnl 'test-realloc-posix', 'test-calloc-gnu' fail.
case "$host_os" in
mingw* | windows*)
gl_cv_func_malloc_posix=no ;;
# realloc.m4
-# serial 33
+# serial 34
dnl Copyright (C) 2007, 2009-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AS_CASE([$ac_cv_func_realloc_0_nonnull], [*yes], [$1], [$2])
])# AC_FUNC_REALLOC
-# gl_FUNC_REALLOC_GNU
-# -------------------
-# Replace realloc if it is not compatible with GNU libc.
-AC_DEFUN([gl_FUNC_REALLOC_GNU],
-[
- AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
- AC_REQUIRE([gl_FUNC_REALLOC_POSIX])
-
- dnl Through the dependency on module extensions-aix, _LINUX_SOURCE_COMPAT
- dnl gets defined already before this macro gets invoked. This helps
- dnl if !(__VEC__ || __AIXVEC), and doesn't hurt otherwise.
-
- AC_REQUIRE([gl_FUNC_REALLOC_SANITIZED])
- if test "$gl_cv_func_realloc_sanitize" = no \
- && test $REPLACE_REALLOC_FOR_REALLOC_GNU = 0; then
- _AC_FUNC_REALLOC_IF([], [REPLACE_REALLOC_FOR_REALLOC_GNU=1])
- fi
-])# gl_FUNC_REALLOC_GNU
-
# gl_FUNC_REALLOC_POSIX
# ---------------------
# Test whether 'realloc' is POSIX compliant (sets errno to ENOMEM when it
# stdlib_h.m4
-# serial 81
+# serial 82
dnl Copyright (C) 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RANDOM_R])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOCARRAY])
- gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_GNU])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALLOC_POSIX])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REALPATH])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RPMATCH])
REPLACE_RAND=0; AC_SUBST([REPLACE_RAND])
REPLACE_RANDOM=0; AC_SUBST([REPLACE_RANDOM])
REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
- REPLACE_REALLOC_FOR_REALLOC_GNU=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_GNU])
REPLACE_REALLOC_FOR_REALLOC_POSIX=0; AC_SUBST([REPLACE_REALLOC_FOR_REALLOC_POSIX])
REPLACE_REALLOCARRAY=0; AC_SUBST([REPLACE_REALLOCARRAY])
REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
Description:
realloc() function that is glibc compatible.
+Status:
+deprecated
+
+Notice:
+This module is deprecated. Use the module 'filename' instead.
+
Files:
-lib/realloc.c
Depends-on:
realloc-posix
-extensions-aix
-free-posix [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
-malloc-gnu [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
-xalloc-oversized [test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1]
configure.ac:
-gl_FUNC_REALLOC_GNU
-if test $REPLACE_REALLOC_FOR_REALLOC_GNU = 1; then
- AC_LIBOBJ([realloc])
-fi
-gl_STDLIB_MODULE_INDICATOR([realloc-gnu])
Makefile.am:
LGPLv2+
Maintainer:
-Jim Meyering
+all
+++ /dev/null
-Files:
-tests/test-realloc-gnu.c
-tests/macros.h
-
-Depends-on:
-stdint
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-realloc-gnu
-check_PROGRAMS += test-realloc-gnu
--- /dev/null
+Files:
+tests/test-realloc-posix.c
+tests/macros.h
+
+Depends-on:
+stdint
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-realloc-posix
+check_PROGRAMS += test-realloc-posix
-e 's/@''GNULIB_RAND''@/$(GNULIB_RAND)/g' \
-e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
-e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
- -e 's/@''GNULIB_REALLOC_GNU''@/$(GNULIB_REALLOC_GNU)/g' \
-e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
-e 's/@''GNULIB_REALLOCARRAY''@/$(GNULIB_REALLOCARRAY)/g' \
-e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
-e 's|@''REPLACE_RAND''@|$(REPLACE_RAND)|g' \
-e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
-e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
- -e 's|@''REPLACE_REALLOC_FOR_REALLOC_GNU''@|$(REPLACE_REALLOC_FOR_REALLOC_GNU)|g' \
-e 's|@''REPLACE_REALLOC_FOR_REALLOC_POSIX''@|$(REPLACE_REALLOC_FOR_REALLOC_POSIX)|g' \
-e 's|@''REPLACE_REALLOCARRAY''@|$(REPLACE_REALLOCARRAY)|g' \
-e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
int
main (int argc, _GL_UNUSED char **argv)
{
+ void *volatile p;
+
/* Check that realloc (NULL, 0) is not a NULL pointer. */
- void *volatile p = realloc (NULL, 0);
+ p = realloc (NULL, 0);
+ ASSERT (p != NULL);
+#ifdef NOT_YET
+ free (p);
+
+ /* Check that realloc (p, 0) for non-NULL p is not a NULL pointer. */
+ p = malloc (200);
+ p = realloc (p, 0);
+ ASSERT (p != NULL);
+ free (p);
+
+ /* Check that realloc (p, 0) for non-NULL p is not a NULL pointer. */
+ p = malloc (2 * 1024 * 1024);
+ p = realloc (p, 0);
ASSERT (p != NULL);
+#endif
/* Check that realloc (p, n) fails when p is non-null and n exceeds
PTRDIFF_MAX. */