qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free
Date: Fri, 10 Oct 2014 21:44:59 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1

On 10/10/2014 09:32 PM, Gonglei wrote:

>>> Actually, I had noted that C standard says it is a no-operation.
>>> But that doesn't mean that every C-library handles it like that.
>>
>> EVERY libc that is C89 compliant handles it like that.  The last
>> platform that failed on free(NULL) was SunOS 4, which is such
>> museum-ware it's not funny.  There is no need to cater to platforms from
>> 25 years ago.

> 
> But why some callers make a check,
> but some other callers don't do this check?

Because some people haven't learned that free(NULL) is safe yet.  You're
welcome to simplify code as you touch it.

> Can I consider those check is superfluous?

Yes.  Checking for NULL before calling free() or g_free() is wasted effort.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]