This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] avoid calling alloca(0)
On Sat, Nov 19, 2016 at 04:43:29PM -0700, Martin Sebor wrote:
> Thanks for calling out the realloc(0, p) case! Realloc(0, p) is
?? The DR you refer to deprecates realloc(p, 0), not realloc(0, p).
The latter is used much more widely, e.g. by not special casing
the first allocation. So you use
void *p = NULL;
for (...)
{
void *q = realloc (p, sz);
if (q == NULL)
whatever;
p = q;
...
}
Jakub