+2020-12-17 Bruno Haible <bruno@clisp.org>
+
+ free: Fix warning.
+ Reported by Pádraig Brady <P@draigBrady.com> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2020-12/msg00148.html>.
+ * lib/stdlib.in.h (free): New declaration.
+ * m4/stdlib_h.m4 (gl_STDLIB_H): Test whether 'free' is declared.
+ (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_FREE, REPLACE_FREE.
+ * modules/stdlib (Makefile.am): Substitute GNULIB_FREE, REPLACE_FREE.
+ * m4/free.m4 (gl_FUNC_FREE): Set REPLACE_FREE, instead of defining
+ 'free' as a macro here.
+ * modules/free (Depends-on): Add stdlib.
+ (configure.ac): Test REPLACE_FREE. Invoke gl_STDLIB_MODULE_INDICATOR.
+
2020-12-17 Paul Eggert <eggert@cs.ucla.edu>
canonicalize-lgpl: fix AIX test failures
_GL_CXXALIASWARN (fcvt);
#endif
+#if @GNULIB_FREE@
+# if @REPLACE_FREE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef free
+# define free rpl_free
+# endif
+_GL_FUNCDECL_RPL (free, void, (void *ptr));
+_GL_CXXALIAS_RPL (free, void, (void *ptr));
+# else
+_GL_CXXALIAS_SYS (free, void, (void *ptr));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (free);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef free
+/* Assume free is always declared. */
+_GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
+ "use gnulib module free for portability");
+#endif
+
/* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
required. In C++ with GNULIB_NAMESPACE, avoid differences between
platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
-# Check whether free (NULL) is supposed to work.
-
+# free.m4 serial 1
# Copyright (C) 2003-2005, 2009-2020 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
AC_DEFUN([gl_FUNC_FREE],
[
+ AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_CACHE_CHECK([whether free (NULL) is known to work],
[gl_cv_func_free],
case $gl_cv_func_free,$gl_cv_func_free_preserves_errno in
*yes,*yes) ;;
- *)
- AC_DEFINE([free], [rpl_free],
- [Define to rpl_free if the replacement function should be used.])
- ;;
+ *) REPLACE_FREE=1 ;;
esac
])
-# stdlib_h.m4 serial 52
+# stdlib_h.m4 serial 53
dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
#if HAVE_RANDOM_H
# include <random.h>
#endif
- ]], [_Exit aligned_alloc atoll canonicalize_file_name
+ ]], [_Exit aligned_alloc atoll canonicalize_file_name free
getloadavg getsubopt grantpt
initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
posix_memalign posix_openpt ptsname ptsname_r qsort_r
GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
+ GNULIB_FREE=0; AC_SUBST([GNULIB_FREE])
GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
REPLACE_ALIGNED_ALLOC=0; AC_SUBST([REPLACE_ALIGNED_ALLOC])
REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC])
REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
+ REPLACE_FREE=0; AC_SUBST([REPLACE_FREE])
REPLACE_INITSTATE=0; AC_SUBST([REPLACE_INITSTATE])
REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC])
REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
m4/free.m4
Depends-on:
+stdlib
configure.ac:
gl_FUNC_FREE
-case $gl_cv_func_free,$gl_cv_func_free_errno in
- *yes,*yes) ;;
- *)
+if test $REPLACE_FREE = 1; then
AC_LIBOBJ([free])
gl_PREREQ_FREE
- ;;
-esac
+fi
+gl_STDLIB_MODULE_INDICATOR([free])
Makefile.am:
-e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \
-e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \
-e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
+ -e 's/@''GNULIB_FREE''@/$(GNULIB_FREE)/g' \
-e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
-e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
-e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
-e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
-e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
-e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
+ -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
-e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
-e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
-e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \