From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xcnfc-0000qO-NS for qemu-devel@nongnu.org; Fri, 10 Oct 2014 23:48:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcnfW-0004WC-HB for qemu-devel@nongnu.org; Fri, 10 Oct 2014 23:48:40 -0400 Message-ID: <5438A868.1070902@huawei.com> Date: Sat, 11 Oct 2014 11:47:52 +0800 From: Gonglei MIME-Version: 1.0 References: <1412996048-6384-1-git-send-email-arei.gonglei@huawei.com> <54389FB1.8040207@huawei.com> <5438A223.2040402@huawei.com> <5438A349.9090403@redhat.com> <5438A4E2.4090007@huawei.com> <5438A7BB.3060109@redhat.com> In-Reply-To: <5438A7BB.3060109@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] oslib-posix: change free to g_free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: "kwolf@redhat.com" , "Huangweidong (C)" , Zhanghailiang , "qemu-trivial@nongnu.org" , "qemu-devel@nongnu.org" , "stefanha@redhat.com" , "pbonzini@redhat.com" On 2014/10/11 11:44, Eric Blake wrote: > 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. > OK, I will. Thanks again :) >> Can I consider those check is superfluous? > > Yes. Checking for NULL before calling free() or g_free() is wasted effort. > Best regards, -Gonglei