+2020-12-18 Bruno Haible <bruno@clisp.org>
+
+ free: Remove support for obsolete platforms.
+ * m4/free.m4 (gl_FUNC_FREE): Assume free(NULL) works. Don't define
+ CANNOT_FREE_NULL.
+ * lib/free.c (rpl_free): Don't test CANNOT_FREE_NULL.
+ * modules/free (Description): Update.
+ * doc/posix-functions/free.texi: Don't mention SunOS 4 any more.
+
2020-12-18 Paul Eggert <eggert@cs.ucla.edu>
intprops: port to ICC 2021.1 Beta 20201112
Portability problems fixed by Gnulib:
@itemize
-@item
-On old platforms such as SunOS4, @code{free (NULL)} fails.
-However, since all such systems are so old as to no longer
-be considered ``reasonable portability targets,''
-this module is no longer useful.
@end itemize
Portability problems not fixed by Gnulib:
-/* Work around incompatibility on older systems where free (NULL) fails.
+/* Make free() preserve errno.
Copyright (C) 2003, 2006, 2009-2020 Free Software Foundation, Inc.
/* written by Paul Eggert */
#include <config.h>
-#undef free
#include <stdlib.h>
void
rpl_free (void *p)
+#undef free
{
-#ifdef CANNOT_FREE_NULL
- if (!p)
- return;
-#endif
-
int err = errno;
free (p);
errno = err;
-# free.m4 serial 1
+# free.m4 serial 2
# 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,
# Written by Paul Eggert.
-# We can't test for free (NULL) even at runtime, since it might
-# happen to "work" for our test program, but not in general. So, be
-# conservative and use feature tests for relatively modern hosts,
-# where free (NULL) is known to work. This costs a bit of
-# performance on some older hosts, but we can fix that later if
-# needed.
-
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 "$host_os" in
- mingw*) gl_cv_func_free=yes ;;
- *)
- AC_COMPILE_IFELSE(
- [AC_LANG_PROGRAM(
- [[#include <unistd.h>]],
- [[#if _POSIX_VERSION < 199009L && \
- (defined unix || defined _unix || defined _unix_ \
- || defined __unix || defined __unix__)
- #error "'free (NULL)' is not known to work"
- #endif]])],
- [gl_cv_func_free=yes],
- [gl_cv_func_free=no])
- esac
- ])
dnl In the next release of POSIX, free must preserve errno.
dnl https://www.austingroupbugs.net/view.php?id=385
esac
])
- if test $gl_cv_func_free = no; then
- AC_DEFINE([CANNOT_FREE_NULL], [1],
- [Define to 1 if free (NULL) does not work.])
- fi
-
- case $gl_cv_func_free,$gl_cv_func_free_preserves_errno in
- *yes,*yes) ;;
+ case $gl_cv_func_free_preserves_errno in
+ *yes) ;;
*) REPLACE_FREE=1 ;;
esac
])