# HG changeset patch # User Paul Eggert # Date 1086061785 0 # Node ID 5f558ceff8fb11c292d728081448e6a20d60f14e # Parent d4c310e7951fd7bfc0611a6cf83044695982d2e2 Remove dependency of hash and xalloc modules on the malloc and realloc modules. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-05-30 Paul Eggert + * modules/hash (Depends-on): Remove malloc, realloc. + * modules/xalloc (Depends-on): Likewise. + * README: Mention that the 'free' module works around the problem with 'free (0)'. Mention LIA-1 and C99. diff --git a/lib/ChangeLog b/lib/ChangeLog --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2004-05-30 Paul Eggert + + * xmalloc.c (HAVE_MALLOC, HAVE_REALLOC): Do not require these + macros to be defined. + (xnmalloc_inline, xnrealloc_inline, xcalloc): Do not die if + the allocator returns NULL because the requested size is zero. + 2004-05-20 Paul Eggert * malloc/obstack.c (_obstack) [defined _LIBC]: Bring back this diff --git a/lib/xmalloc.c b/lib/xmalloc.c --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -1,7 +1,7 @@ /* xmalloc.c -- malloc with out of memory checking Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2003, - 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + 1999, 2000, 2002, 2003, 2004 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 @@ -37,14 +37,6 @@ # define SIZE_MAX ((size_t) -1) #endif -#ifndef HAVE_MALLOC -"you must run the autoconf test for a GNU libc compatible malloc" -#endif - -#ifndef HAVE_REALLOC -"you must run the autoconf test for a GNU libc compatible realloc" -#endif - /* If non NULL, call this function when memory is exhausted. */ void (*xalloc_fail_func) (void) = 0; @@ -71,7 +63,7 @@ xnmalloc_inline (size_t n, size_t s) { void *p; - if (xalloc_oversized (n, s) || ! (p = malloc (n * s))) + if (xalloc_oversized (n, s) || (! (p = malloc (n * s)) && n != 0)) xalloc_die (); return p; } @@ -96,7 +88,7 @@ static inline void * xnrealloc_inline (void *p, size_t n, size_t s) { - if (xalloc_oversized (n, s) || ! (p = realloc (p, n * s))) + if (xalloc_oversized (n, s) || (! (p = realloc (p, n * s)) && n != 0)) xalloc_die (); return p; } @@ -239,7 +231,7 @@ void *p; /* Test for overflow, since some calloc implementations don't have proper overflow checks. */ - if (xalloc_oversized (n, s) || ! (p = calloc (n, s))) + if (xalloc_oversized (n, s) || (! (p = calloc (n, s)) && n != 0)) xalloc_die (); return p; } diff --git a/m4/ChangeLog b/m4/ChangeLog --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2004-05-30 Paul Eggert + + * xalloc.m4 (gl_PREREQ_XMALLOC): Do not require AC_FUNC_MALLOC + or AC_FUNC_REALLOC. + 2004-05-20 Andreas Schwab * free.m4: Replace free if it not known to work, not the other diff --git a/m4/xalloc.m4 b/m4/xalloc.m4 --- a/m4/xalloc.m4 +++ b/m4/xalloc.m4 @@ -1,4 +1,4 @@ -# xalloc.m4 serial 8 +# xalloc.m4 serial 9 dnl Copyright (C) 2002-2004 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -21,8 +21,6 @@ # Prerequisites of lib/xmalloc.c. AC_DEFUN([gl_PREREQ_XMALLOC], [ AC_REQUIRE([AC_C_INLINE]) - AC_REQUIRE([AC_FUNC_MALLOC]) - AC_REQUIRE([AC_FUNC_REALLOC]) : ]) diff --git a/modules/hash b/modules/hash --- a/modules/hash +++ b/modules/hash @@ -7,8 +7,6 @@ m4/hash.m4 Depends-on: -malloc -realloc stdbool configure.ac: diff --git a/modules/xalloc b/modules/xalloc --- a/modules/xalloc +++ b/modules/xalloc @@ -8,8 +8,6 @@ m4/xalloc.m4 Depends-on: -malloc -realloc error gettext exitfail