qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] some questions about g_malloc in qemu


From: Zhi Hui Li
Subject: Re: [Qemu-devel] some questions about g_malloc in qemu
Date: Thu, 15 Dec 2011 17:48:16 +0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

On 2011年12月15日 17:36, Stefan Hajnoczi wrote:
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



Maybe there is insufficient memory, the return is error,
Do we need to check the return ?


Thank you very much for your feedback!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]