qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently


From: jcd
Subject: Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
Date: Mon, 1 Jun 2009 13:24:53 +0100 (GMT+01:00)

----- "Jamie Lokier" <address@hidden> a écrit :

> address@hidden wrote:
> > Hi Kevin,
> > 
> > Thanks for pointing this. I guess it just sounds strange to me that
> > somebody would want to alloc 0 bytes. But why not ...
> 
> Something that nobody pointed out is that sometimes you can have
> zero-length structures these days.  E.g. if you have a struct
> containing a few spinlocks in the Linux kernel, it will be zero
> length
> when built on UP targets.  I doubt if QEMU has any such structures,
> but it's the sort of thing that shouldn't break
> qemu_malloc(sizeof(some_type)).

This is true but the kernel API is also making a clear distinction between the 
NULL returned value for allocation error and the specific ZERO_SIZE_PTR value 
returned for kmalloc(0, XXX). Things don't get mixed ...

JC

> -- Jamie




reply via email to

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