From: Florian Weimer <fweimer@redhat.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Paul Zimmermann <Paul.Zimmermann@inria.fr>, libc-alpha@sourceware.org
Subject: Re: Fix REALLOC_ZERO_BYTES_FREES comment
Date: Mon, 12 Apr 2021 09:53:35 +0200 [thread overview]
Message-ID: <87eefgndkw.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <a7da171a-5796-5859-6d08-08f229840579@cs.ucla.edu> (Paul Eggert's message of "Mon, 12 Apr 2021 00:48:02 -0700")
* Paul Eggert:
> diff --git a/malloc/malloc.c b/malloc/malloc.c
> index 0cd3ba78ca..e2d7b1b583 100644
> --- a/malloc/malloc.c
> +++ b/malloc/malloc.c
> @@ -346,13 +346,14 @@ __malloc_assert (const char *assertion, const char *file, unsigned int line,
> #define REVEAL_PTR(ptr) PROTECT_PTR (&ptr, ptr)
>
> /*
> - REALLOC_ZERO_BYTES_FREES controls the behavior of realloc (p, 0)
> - when p is nonnull. If nonzero, realloc (p, 0) should free p and
> - return NULL. Otherwise, realloc (p, 0) should do the equivalent
> - of freeing p and returning what malloc (0) would return.
> -
> - ISO C17 says the behavior is implementation-defined here; glibc
> - follows historical practice and defines it to be nonzero.
> + The REALLOC_ZERO_BYTES_FREES macro controls the behavior of realloc (p, 0)
> + when p is nonnull. If the macro is nonzero, the realloc call returns NULL;
> + otherwise, the call returns what malloc (0) would. In either case,
> + p is freed. Glibc uses a nonzero REALLOC_ZERO_BYTES_FREES, which
> + implements common historical practice.
> +
> + ISO C17 says the realloc call has implementation-defined behavior,
> + and it might not even free p.
> */
I think this is a really good explanation of the situation. Thanks.
Florian
next prev parent reply other threads:[~2021-04-12 7:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-11 21:42 Paul Eggert
2021-04-12 6:05 ` Paul Zimmermann
2021-04-12 6:13 ` Florian Weimer
2021-04-12 6:19 ` Paul Zimmermann
2021-04-12 7:48 ` Paul Eggert
2021-04-12 7:53 ` Florian Weimer [this message]
2021-04-12 19:44 ` DJ Delorie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eefgndkw.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=Paul.Zimmermann@inria.fr \
--cc=eggert@cs.ucla.edu \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).