From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPf5v-0007dk-DE for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:29:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPf5m-0002yr-Ga for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:29:15 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:37227) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPf5m-0002ye-6X for qemu-devel@nongnu.org; Mon, 17 Mar 2014 17:29:06 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Mar 2014 21:29:05 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 01D591B08040 for ; Mon, 17 Mar 2014 21:28:52 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s2HLSo6E197002 for ; Mon, 17 Mar 2014 21:28:50 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s2HLT2tN000956 for ; Mon, 17 Mar 2014 17:29:02 -0400 Message-ID: <5327691D.3040906@de.ibm.com> Date: Mon, 17 Mar 2014 22:29:01 +0100 From: Christian Borntraeger MIME-Version: 1.0 References: <5327618D.5070007@de.ibm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 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: Peter Maydell Cc: "Michael S. Tsirkin" , "qemu-devel@nongnu.org" , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , Marcel Apfelbaum 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? Christian > If you really dislike the const I guess you could use: > char *name = g_strconcat(...); > TypeInfo ti = { > .name = name, > [...] > }; > [...] > g_free(name); >