memory allocations for libraries used by libvirt

Olaf Hering olaf at
Wed May 19 20:30:30 UTC 2021

Currently src/libxl/ allocates a bunch of buffers with variants of g_new0() or g_strdup(), which will be consumed by Once the objects which contain these buffers are not needed anymore, will release them with ordinary calls to free() in its *_dispose() API. In other words: does not use glib.

While the g_malloc docs of today's glib state that (apparently) the mistake of using a private allocator was recognized and corrected in glib 2.46, the same mistake might occur again in the future.

I wonder if a patch will be accepted which will add simple wrappers around calloc, strdup, like libxlCallocWrap and libxlStrupWrap, which provides the buffers expected by and which it can simply free() again. Just so that it looks more "symmetric", as opposed to g_new0()/free() pairs.

Maybe this issue was already evaluated at the time libvirt was converted from virAlloc to g_new?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: Digitale Signatur von OpenPGP
URL: <>

More information about the libvir-list mailing list