Re: g_utf16_to_utf8
- From: Fabrício Godoy <skarllot gmail com>
- To: Hubert Figuiere <hub figuiere net>
- Cc: gtkmm-list gnome org
- Subject: Re: g_utf16_to_utf8
- Date: Fri, 17 Apr 2009 15:48:03 -0300
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
<hub figuiere net>
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]