qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0
Date: Tue, 19 May 2009 21:32:23 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Eduardo Habkost wrote:
> Now, _that_ sounds like a really bad idea. realloc(NULL, n) is specified
> to be equivalent to malloc(n).

No it isn't.  You can't make that substitution.

In the case where n == 0, realloc(NULL, n) is guaranteed to not
allocate anything and return NULL, whereas malloc(n) does not
guarantee that and in fact doesn't do that on a lot of implementations.

-- Jamie




reply via email to

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