qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [patch] replace all strdup() with g_strdup()


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [patch] replace all strdup() with g_strdup()
Date: Fri, 16 Dec 2011 11:21:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1

On 12/16/2011 10:41 AM, Daniel P. Berrange wrote:
Yes&  no. In general you are correct that g_malloc/g_strdup needs to
be matched with g_free, but in the context of the QEMU binary at least
we don't strictly need that.

The general issue is that GLib's memory allocators default to the
system malloc/free, but with    g_mem_set_vtable   it is possible
to override those allocators.

So any libraries using GLib should definitely take care to match
g_malloc/g_strdup/g_free, but if you are a self contained program
that never calls g_mem_set_vtable, we don't technically have to
worry about it.

I think the keyword here is "technically". :) If we want to use the GLib profiling allocators or any other kind of statistic gathering, we do have to match the allocations. Right now, we're not getting it 100% right, but sweeping conversions make it harder to just grep-w for malloc/free/strdup.

Paolo



reply via email to

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