[Top][All Lists]

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

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

From: Julian Seward
Subject: Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
Date: Fri, 29 May 2009 19:17:10 +0200
User-agent: KMail/1.9.9

On Friday 29 May 2009, Paul Brook wrote:
> >(e) return malloc(0), without wrapping it into oom_check().
> This is the worst of both worlds.
> > For the purpose of finding broken code returning NULL is IMHO the best
> > option.  Although dereferencing NULL is undefined, in practice it will
> > segfault in most cases so the bugs shouldn't stay unnoticed for long.
> The best way to find broken code is to have qemu_malloc(0) abort, and avoid
> ever trying to allocate a zero size block.

+1 for that.  Code that relies on malloc(0) doing any specific thing
is basically bad news when it comes to portability, robustness
and understandability.  Better to have qemu_malloc(0) abort, put up with
a couple of days of the trunk aborting, until these uses are fixed.
I'd be surprised if there were many cases anyway.


reply via email to

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