]> Savannah Git Hosting - gnulib.git/commitdiff
free: Remove support for obsolete platforms.
authorBruno Haible <bruno@clisp.org>
Fri, 18 Dec 2020 22:58:37 +0000 (23:58 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 18 Dec 2020 22:58:37 +0000 (23:58 +0100)
* 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.

ChangeLog
doc/posix-functions/free.texi
lib/free.c
m4/free.m4
modules/free

index c723356c11a9600dd5982f49045cbbca9a464c74..14db75ab280c73c0e2f849a9e84568e38d4dd19f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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
index ba3484c2705279c791984171aeb76b728804a208..1c397d14ee62ef5c9ba52f6a123c97aa6cbd3d4c 100644 (file)
@@ -8,11 +8,6 @@ Gnulib module: free
 
 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:
index 843ce4816b4148243a79cbb92face90e0e7c98c8..2f689a7ea32e1a84f9fbc3699f5b4e5183576dc5 100644 (file)
@@ -1,4 +1,4 @@
-/* Work around incompatibility on older systems where free (NULL) fails.
+/* Make free() preserve errno.
 
    Copyright (C) 2003, 2006, 2009-2020 Free Software Foundation, Inc.
 
@@ -18,7 +18,6 @@
 /* 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;
index 9f108c184de9d1100d860efac7d04c166ae31510..fb191df1e4eb0ce448cd2862d233910a6ec0ebb0 100644 (file)
@@ -1,4 +1,4 @@
-# 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,
@@ -6,34 +6,10 @@
 
 # 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
@@ -60,13 +36,8 @@ AC_DEFUN([gl_FUNC_FREE],
      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
 ])
index dc5cb56c47c12683ceca8c2c31c1670dd94fa2ed..29ec637bd751c256d2cd2aeb7f5852e0a473509c 100644 (file)
@@ -1,5 +1,5 @@
 Description:
-Work around systems where free sets errno or free (NULL) fails.
+Work around systems where free clobbers errno.
 
 Files:
 lib/free.c