Re: g_utf16_to_utf8



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]