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

Re: [Libvir] [PATCH] Detect heap allocation failure; factor out some duplication.



On Wed, Nov 28, 2007 at 02:18:22PM +0100, Jim Meyering wrote:
> I spotted a few unchecked heap allocations (strdup, malloc, calloc)
> in qemud.c and have fixed it so such failure evokes a proper diagnostic
> rather than e.g., a segfault.

Yep, good stuff.

> I've also arranged to free some of the memory upon failure,
> but not all (see comments for why).
> 
> In spite of those additions, this patch factors out enough
> duplication that the net change is to remove a few lines from the
> file.  Although in general I prefer to factor things out into
> separate functions, in this case, it seemed better to use macros.

I really don't like the macros, particularly when the macro definitions
are inline to the function. I'd prefer to see these helpers as separate
functions. The compiler is perfectly able to decide whether to inline 
the code or not & it makes it more friendly to edit & read when it is 
using separate functions.

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 


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