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 16:20:31 -0300
2009/4/17 Hubert Figuiere
<hub figuiere net>
On 04/17/2009 02:48 PM, Fabrício Godoy wrote:
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;
}
Without even the need for you to tell me to define "without success" (yes this is far to vague to even be a useful statement), I can tell you that you should re-read the documentation for Glib::RefPtr<> as you are misusing it.
Glib::ustring accepts a "gchar*" but not a gchar wrapped by RefPtr.
*hint*: the doc for g_utf16_to_utf8() tells you that the pointer needs to be freed with g_free(). Why don't you just do that?
win_NetworkInterface class is a specialization of NetworkInterface abstract class.
The NetworkInterface class defines "get_name" to return "Glib::ustring".
And I want to keep this as is, to enjoy ustring facilities.
Thanks.
Hub
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]