From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb7k6-0008QU-PL for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:36:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb7k1-0003bm-7l for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:36:46 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:37988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb7k1-0003bc-2D for qemu-devel@nongnu.org; Thu, 15 Dec 2011 04:36:41 -0500 Received: by eekb45 with SMTP id b45so2002228eek.4 for ; Thu, 15 Dec 2011 01:36:40 -0800 (PST) Date: Thu, 15 Dec 2011 09:36:37 +0000 From: Stefan Hajnoczi Message-ID: <20111215093637.GA387@stefanha-thinkpad.localdomain> References: <4EE9AB5A.4080306@linux.vnet.ibm.com> <20111215082828.GA33201@cs.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20111215082828.GA33201@cs.nctu.edu.tw> Subject: Re: [Qemu-devel] some questions about g_malloc in qemu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?B?6Zmz6Z+L5Lu7?= Cc: Kevin Wolf , Zhi Hui Li , zhihuili@cn.ibm.com, Stefan Hajnoczi , QEMU-devel On Thu, Dec 15, 2011 at 04:28:28PM +0800, 陳韋任 wrote: > I found this in HACKING: > > Please note that NULL check for the g_malloc result is redundant and > that g_malloc() call with zero size is not allowed. So we have: 1. You should not request 0 bytes from g_malloc(). 2. g_malloc() does not return NULL (if you follow rule #1). There is no need to check for NULL return. Stefan