On 17/03/14 22:25, Peter Maydell wrote: > On 17 March 2014 20:56, Christian Borntraeger <borntrae...@de.ibm.com> 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); >