X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Frealloc.c;h=7620b6a924010ad98b09f9bd02a59b22ad3202e6;hb=a8a88eddaa90432e6ec1b8d9d5c9842bc91afd1d;hp=b61c2ca8294d05ba5561ff0ba380d33cd5748368;hpb=c7e61475680fa226bd9b8bdd469cd66914e630f5;p=debian%2Fgzip diff --git a/lib/realloc.c b/lib/realloc.c index b61c2ca..7620b6a 100644 --- a/lib/realloc.c +++ b/lib/realloc.c @@ -1,6 +1,7 @@ /* realloc() function that is glibc compatible. - Copyright (C) 1997, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 1997, 2003-2004, 2006-2007, 2009-2018 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 @@ -13,40 +14,31 @@ 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, see . */ + along with this program. If not, see . */ /* written by Jim Meyering and Bruno Haible */ +#define _GL_USE_STDLIB_ALLOC 1 #include /* Only the AC_FUNC_REALLOC macro defines 'realloc' already in config.h. */ #ifdef realloc # define NEED_REALLOC_GNU 1 +/* Whereas the gnulib module 'realloc-gnu' defines HAVE_REALLOC_GNU. */ +#elif GNULIB_REALLOC_GNU && !HAVE_REALLOC_GNU +# define NEED_REALLOC_GNU 1 #endif /* Infer the properties of the system's malloc function. - Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ -#if GNULIB_MALLOC_GNU && !defined malloc + The gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */ +#if GNULIB_MALLOC_GNU && HAVE_MALLOC_GNU # define SYSTEM_MALLOC_GLIBC_COMPATIBLE 1 #endif -/* Below we want to call the system's malloc and realloc. - Undefine the symbols here so that including provides a - declaration of malloc(), not of rpl_malloc(), and likewise for realloc. */ -#undef malloc -#undef realloc - -/* Specification. */ #include #include -/* Below we want to call the system's malloc and realloc. - Undefine the symbols, if they were defined by gnulib's - replacement. */ -#undef malloc -#undef realloc - /* Change the size of an allocated block of memory P to N bytes, with error checking. If N is zero, change it to 1. If P is NULL, use malloc. */ @@ -71,7 +63,7 @@ rpl_realloc (void *p, size_t n) { #if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE if (n == 0) - n = 1; + n = 1; #endif result = malloc (n); }