From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPfJR-0003aZ-Ob for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPfJH-0006qy-Tc for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:43:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPfJH-0006qr-MT for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:43:03 -0400 Message-ID: <1395092601.3377.2.camel@localhost.localdomain> From: Marcel Apfelbaum Date: Mon, 17 Mar 2014 23:43:21 +0200 In-Reply-To: <5327691D.3040906@de.ibm.com> References: <5327618D.5070007@de.ibm.com> <5327691D.3040906@de.ibm.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] small memory leak due to MachineClass rework List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christian Borntraeger Cc: Peter Maydell , "Michael S. Tsirkin" , "qemu-devel@nongnu.org" , Andreas =?ISO-8859-1?Q?F=E4rber?= On Mon, 2014-03-17 at 22:29 +0100, Christian Borntraeger wrote: > On 17/03/14 22:25, Peter Maydell wrote: > > On 17 March 2014 20:56, Christian Borntraeger wrote: > >> Turns out that valgrind is right. We simply forget the memory that g_strconcat has allocated. > >> This fixes the small leak, but I have to cast away the constness of .name. > >> Any better ideas? > > > > It's how cpu_register() in target-arm/cpu.c does the same thing > > (though we use void* rather than gpointer as the cast). > > Ok, if you dont have a problem with that approach, I can submit a proper > patch with signoff. Any preference regarding void * vs gpointer? Hi Cristian, Thank you for catching this! (I also would go with void *) Marcel > > Christian > > > > If you really dislike the const I guess you could use: > > char *name = g_strconcat(...); > > TypeInfo ti = { > > .name = name, > > [...] > > }; > > [...] > > g_free(name); > > > >