diff options
Diffstat (limited to 'macros/texinfo/texinfo/gnulib/lib/malloc.c')
-rw-r--r-- | macros/texinfo/texinfo/gnulib/lib/malloc.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/macros/texinfo/texinfo/gnulib/lib/malloc.c b/macros/texinfo/texinfo/gnulib/lib/malloc.c index 76e6ff764b..1fc8b91b92 100644 --- a/macros/texinfo/texinfo/gnulib/lib/malloc.c +++ b/macros/texinfo/texinfo/gnulib/lib/malloc.c @@ -1,6 +1,6 @@ /* malloc() function that is glibc compatible. - Copyright (C) 1997-1998, 2006-2007, 2009-2019 Free Software Foundation, Inc. + Copyright (C) 1997-1998, 2006-2007, 2009-2021 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 @@ -30,7 +30,11 @@ #include <stdlib.h> -#include <errno.h> +/* A function definition is only needed if NEED_MALLOC_GNU is defined above + or if the module 'malloc-posix' requests it. */ +#if NEED_MALLOC_GNU || (GNULIB_MALLOC_POSIX && !HAVE_MALLOC_POSIX) + +# include <errno.h> /* Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block. */ @@ -40,17 +44,19 @@ rpl_malloc (size_t n) { void *result; -#if NEED_MALLOC_GNU +# if NEED_MALLOC_GNU if (n == 0) n = 1; -#endif +# endif result = malloc (n); -#if !HAVE_MALLOC_POSIX +# if !HAVE_MALLOC_POSIX if (result == NULL) errno = ENOMEM; -#endif +# endif return result; } + +#endif |