[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:26:01 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 |
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.
> 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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature