[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free
From: |
Gonglei |
Subject: |
Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free |
Date: |
Sat, 11 Oct 2014 11:32:50 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 |
On 2014/10/11 11:26, Eric Blake wrote:
> On 10/10/2014 09:21 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.
>
OK.Thanks for explanation!
>> Some people saw crashes for free(NULL), so it's best to avoid
>> calling the free in the first place (caller) or using g_free() in
>> qemu_vfree().
>
> Absolutely not. g_free is unsafe to use except for pointers from
> g_malloc, which is NOT the case that qemu_vfree is used on.
>
Got it, thanks :)
But why some callers make a check,
but some other callers don't do this check?
Can I consider those check is superfluous?
-Best regards,
-Gonglei
Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free, Eric Blake, 2014/10/10