Mercurial > hg > octave-nkf > gnulib-hg
changeset 4753:6b790c4dd07d
Add 'free' module.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 27 Sep 2003 16:13:48 +0000 |
parents | d0f300fb7b8b |
children | c6f70c2457d2 |
files | ChangeLog lib/ChangeLog lib/free.c m4/ChangeLog m4/free.m4 modules/free |
diffstat | 6 files changed, 111 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-09-27 Paul Eggert <eggert@twinsun.com> + + * modules/free: New file. + 2003-09-25 Bruno Haible <bruno@clisp.org> * modules/version-etc-2: New file, from modules/version-etc with
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-09-27 Paul Eggert <eggert@twinsun.com> + + * free.c: New file. + 2003-09-26 Jim Meyering <jim@meyering.net> * error.c (error_tail): Move some declarations
new file mode 100644 --- /dev/null +++ b/lib/free.c @@ -0,0 +1,33 @@ +/* Work around incompatibility on older systems where free (NULL) fails. + + Copyright (C) 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* written by Paul Eggert */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif +#undef free + +#include <stdlib.h> + +void +rpl_free (void *p) +{ + if (p) + free (p); +}
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2003-09-27 Paul Eggert <eggert@twinsun.com> + + * free.m4: New file. + 2003-09-26 Bruno Haible <bruno@clisp.org> * stpncpy.m4 (gl_FUNC_STPNCPY): Add comments about the AIX stpncpy().
new file mode 100644 --- /dev/null +++ b/m4/free.m4 @@ -0,0 +1,46 @@ +# Check whether free (NULL) is supposed to work. + +# Copyright (C) 2003 Free Software Foundation, Inc. + +# This file is free software, distributed under the terms of the GNU +# General Public License. As a special exception to the GNU General +# Public License, this file may be distributed as part of a program +# that contains a configuration script generated by Autoconf, under +# the same distribution terms as the rest of that program. + +# 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_CHECK_HEADERS_ONCE(unistd.h) + AC_CACHE_CHECK([whether free (NULL) is known to work], + [gl_cv_func_free], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[@%:@if HAVE_UNISTD_H + @%:@include <unistd.h> + @%:@endif]], + [[@%:@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])]) + + if test $gl_cv_func_free = yes; then + AC_LIBOBJ(free) + AC_DEFINE(free, rpl_free, + [Define to rpl_free if the replacement function should be used.]) + fi +]) + +# Prerequisites of lib/free.c. +AC_DEFUN([gl_PREREQ_FREE], [:])
new file mode 100644 --- /dev/null +++ b/modules/free @@ -0,0 +1,20 @@ +Description: +Work around incompatibility on older systems where free (NULL) fails. + +Files: +lib/free.c +m4/free.m4 + +Depends-on: + +configure.ac: +gl_FUNC_FREE + +Makefile.am: + +Include: +<stdlib.h> + +Maintainer: +Paul Eggert +