diff options
author | Bruno Haible <bruno@clisp.org> | 2021-01-31 12:41:33 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2021-01-31 12:42:01 +0100 |
commit | 3dfe86d1522029f12c84bec55c8fb3c6c9c561dc (patch) | |
tree | 6a07117974d0d84bf1021657001b090e7580ab0d /lib/free.c | |
parent | 64bdee095f60ec708937d73132b95377e27a827e (diff) | |
download | gnulib-3dfe86d1522029f12c84bec55c8fb3c6c9c561dc.tar.gz |
Make it possible to compile free.c separately, unconditionally.
* m4/free.m4 (gl_FUNC_FREE): Define HAVE_FREE_POSIX.
* lib/free.c: Don't define rpl_free if not needed.
Diffstat (limited to 'lib/free.c')
-rw-r--r-- | lib/free.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/free.c b/lib/free.c index 5c89787aba..3f5968ca99 100644 --- a/lib/free.c +++ b/lib/free.c @@ -19,15 +19,19 @@ #include <config.h> +/* Specification. */ #include <stdlib.h> -#include <errno.h> +/* A function definition is only needed if HAVE_FREE_POSIX is not defined. */ +#if !HAVE_FREE_POSIX + +# include <errno.h> void rpl_free (void *p) -#undef free +# undef free { -#if defined __GNUC__ && !defined __clang__ +# if defined __GNUC__ && !defined __clang__ /* An invalid GCC optimization <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396> would optimize away the assignments in the code below, when link-time @@ -39,9 +43,11 @@ rpl_free (void *p) errno = 0; free (p); errno = err[errno == 0]; -#else +# else int err = errno; free (p); errno = err; -#endif +# endif } + +#endif |