* modules/realloc-posix (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/realloc.c: Don't define rpl_realloc if not needed.
2021-01-31 Bruno Haible <bruno@clisp.org>
+ Make it possible to compile realloc.c separately, unconditionally.
+ * modules/realloc-posix (configure.ac): Invoke gl_MODULE_INDICATOR.
+ * lib/realloc.c: Don't define rpl_realloc if not needed.
+
Make it possible to compile malloc.c separately, unconditionally.
* modules/malloc-posix (configure.ac): Invoke gl_MODULE_INDICATOR.
* lib/malloc.c: Don't define rpl_malloc if not needed.
#include <stdlib.h>
-#include <errno.h>
+/* A function definition is only needed if NEED_REALLOC_GNU is defined above
+ or if the module 'realloc-posix' requests it. */
+#if NEED_REALLOC_GNU || (GNULIB_REALLOC_POSIX && !HAVE_REALLOC_POSIX)
+
+# include <errno.h>
/* 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,
{
void *result;
-#if NEED_REALLOC_GNU
+# if NEED_REALLOC_GNU
if (n == 0)
{
n = 1;
free (p);
p = NULL;
}
-#endif
+# endif
if (p == NULL)
{
-#if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
+# if GNULIB_REALLOC_GNU && !NEED_REALLOC_GNU && !SYSTEM_MALLOC_GLIBC_COMPATIBLE
if (n == 0)
n = 1;
-#endif
+# endif
result = malloc (n);
}
else
result = realloc (p, n);
-#if !HAVE_REALLOC_POSIX
+# if !HAVE_REALLOC_POSIX
if (result == NULL)
errno = ENOMEM;
-#endif
+# endif
return result;
}
+
+#endif
AC_LIBOBJ([realloc])
fi
gl_STDLIB_MODULE_INDICATOR([realloc-posix])
+gl_MODULE_INDICATOR([realloc-posix])
Makefile.am: