bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proper realloc(p,0) behavior?


From: Paul Eggert
Subject: Re: proper realloc(p,0) behavior?
Date: Fri, 25 Mar 2011 09:07:11 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

On 03/24/2011 04:52 PM, Bruno Haible wrote:
>   Leaking memory when you are already out of memory is not a problem: the
>   program will need to terminate very soon anyway. So code which calls
>   realloc(p,0) and does not free p if that returns NULL is just fine.

I hadn't thought of this argument, and it's a good one; thanks.

Come to think of it, I don't know of any implementation where,
if P is nonnull, then realloc (P, 0) can return NULL without
freeing P.  So even though C99 allows such behavior in theory,
are we worrying about a memory-leak issue that is only theoretical?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]