Commit Graph

9 Commits

Author SHA1 Message Date
Daniel P. Berrange
0c4a048485 Fix virRealloc bug for zero-size 2008-10-10 18:17:13 +00:00
Chris Lalancette
0aa6eedddd For 0.4.3, danpb's new memory management scheme went into libvirt. This is
fine, except that is subtly alters the semantics of malloc(), calloc(), and
realloc().  In particular, if you say:

foo = malloc(0);

glibc will happily return a non-NULL pointer to you.  However, with the new
memory management stuff, if you say:

foo = VIR_ALLOC(0);

you will actually get a NULL pointer back.  Personally, I think this is a
dangerous deviation from malloc() semantics that everyone is used to, and is
indeed causing problems with the remote driver.  The short of it is that the
remote driver allocates memory on behalf of the remote side using VIR_ALLOC_N,
and this call is returning NULL so that the NULL checks elsewhere in the code
fire and return failure.

The attached patch fixes this situation by removing the 0 checks from the memory
allocation paths, and just lets them fall through to the normal malloc(),
calloc(), or realloc() routines, restoring old semantics.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2008-06-19 11:58:49 +00:00
Daniel P. Berrange
d789ef5a88 Switch over remaining driver code to use memory alloc apis 2008-06-06 11:09:57 +00:00
Daniel P. Berrange
d7d21c85e0 Switch daemon over to use internal memory allocation APIs 2008-06-06 10:52:01 +00:00
Daniel P. Berrange
e8a0db81ef Pass allocation number to callback 2008-05-29 18:47:00 +00:00
Daniel P. Berrange
18da6991e1 Generic OOM testing hooks 2008-05-29 15:13:07 +00:00
Daniel P. Berrange
2afd1db4a2 Fix build on F9 with missing stddefs.h include 2008-05-06 21:44:12 +00:00
Jim Meyering
724d0df7e5 Avoid "make syntax-check" failures.
* src/memory.c: Include "config.h".
Remove trailing blanks.
2008-04-29 13:37:20 +00:00
Daniel P. Berrange
4ffb0358de Added safer lowlevel memory allocation APis. Converted hash.c and capabilities.c to use them 2008-04-28 21:44:54 +00:00