[Libvir] RFC: safer memory allocation APIs with compile time checking
veillard at redhat.com
Mon Apr 28 17:43:52 UTC 2008
On Mon, Apr 28, 2008 at 05:51:37PM +0100, Daniel P. Berrange wrote:
> On Sun, Apr 27, 2008 at 08:29:33PM +0100, Daniel P. Berrange wrote:
> > After updating the virBuffer APIs to protect against improper usage I have
> > been thinking about how we might provider safer memory allocation APIs
> > with protection against common usage errors and compile time validation of
> > checks for failure.
> Here is an updated version which removes the bogus VIR_REALLOC function
> and illustrates use in capabilities.c which is a more interesting test
> case than hash.c
Clearly that makes for cleaner code, and more importantly safer.
We should do this, possibly one module at a time, then we can try to
add new syntax-check rules forbidding malloc/realloc. Also potentially
we could hook up memory checks at runtime with the macro, if we need
to in the future.
+1 for applying this now, then we can fix one module at a time later.
we don't need to grow a gigantic patch.
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
More information about the libvir-list