From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbUvM-0005Ml-QV for qemu-devel@nongnu.org; Fri, 16 Dec 2011 05:22:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbUvH-00030e-7x for qemu-devel@nongnu.org; Fri, 16 Dec 2011 05:21:56 -0500 Received: from mail-ee0-f45.google.com ([74.125.83.45]:35012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbUvG-00030Z-Uq for qemu-devel@nongnu.org; Fri, 16 Dec 2011 05:21:51 -0500 Received: by eekb45 with SMTP id b45so3379533eek.4 for ; Fri, 16 Dec 2011 02:21:50 -0800 (PST) Sender: Paolo Bonzini Message-ID: <4EEB1BBB.4030003@redhat.com> Date: Fri, 16 Dec 2011 11:21:47 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <4EEB0EC9.6030705@redhat.com> <20111216094117.GB9860@redhat.com> In-Reply-To: <20111216094117.GB9860@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [patch] replace all strdup() with g_strdup() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel , Jun Koi 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