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: Eric Blake
Subject: Re: proper realloc(p,0) behavior?
Date: Fri, 25 Mar 2011 11:45:34 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9

On 03/25/2011 11:40 AM, Paul Eggert wrote:
> On 03/25/2011 09:31 AM, Eric Blake wrote:
>> xrealloc(NULL,0) _must_ return malloc(0) rather than blindly returning NULL.
> 
> Yes, that makes sense too.  Thanks for thinking it through.
> 
> The change you just installed causes xrealloc (NULL, 0)
> to return realloc (NULL, 0) without failing, which boils
> down to the same thing (and is arguably better, on weird
> implementations where malloc (0) and realloc (NULL, 0)
> have different semantics).

Pedantically, any system where malloc(0) and realloc(NULL,0) behave
differently is buggy, since C99 defines the latter in terms of the
former.  :)

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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