2009/4/17 Hubert Figuiere <[email protected]>

> 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
>
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to