RFC: Handling realloc(0)
Mike Frysinger
vapier@gentoo.org
Fri Apr 30 17:56:51 GMT 2021
On 30 Apr 2021 18:02, Nick Clifton via Binutils wrote:
> A recent binutils bug report (PR 27797) has brought to light the fact
> that the behaviour of realloc(0) is not well defined. So I am
> proposing the attached patch to change the behaviour of the
> bfd_realloc and bfd_realloc_or_free functions. With this patch
> applied:
>
> bfd_realloc (NULL, 0) will return bfd_malloc (1)
> bfd_realloc (ptr, 0) will return ptr
> bfd_realloc_of_free (NULL, 0) will return NULL (and no error set)
> bfd_realloc_or_free (ptr, 0) will return NULL and ptr will have been freed.
>
> What do people think ? Any objections ?
afaik, this matches the general GNU behavior (C library & gnulib), so lgtm
-mike
More information about the Binutils
mailing list