Please, how I avoid this leak?
I tried following, without success:
Glib::ustring win_NetworkInterface::get_name()
{
Glib::RefPtr<gchar> cname (g_utf16_to_utf8(
(gunichar2*) this->ifinfo.FriendlyName, -1, NULL, NULL, NULL));
Glib::ustring name(cname);
return name;
}
2009/4/17 Hubert Figuiere <[email protected]>
> On 04/17/2009 12:56 PM, Fabrício Godoy wrote:
>
>> 2- Has memory leak on method below?
>> The generated string from g_utf16_to_utf8 must be freed manually, even
>> when
>> stored in a ustring?
>>
>> Glib::ustring win_NetworkInterface::get_name()
>> {
>> Glib::ustring name(g_utf16_to_utf8((gunichar2*)
>> this->ifinfo.FriendlyName,
>> -1, NULL, NULL, NULL));
>> return name;
>> }
>>
>>
> As per the documentation, g_utf16_to_utf8() return an allocated pointer
> that must be freeed. Also the pointer can be NULL (and that might be a
> problem for Glib::ustring).
>
>
> Glib::ustring never do anything to the pointer it gets passed at
> construction time.
>
> Hub
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list