diff libgaim/plugins/perl/common/typemap @ 15104:53f7a4a8ad2a

[gaim-migrate @ 17889] Fix some leakage in the perl loader bindings by using a special typedef to handle functions that return g_malloc()-ed values. Thanks to the Gtk-Perl folks for any easy way to do this. Fix gaim_gtk_sound_get_event_label() to correctly indicate that the retval is a constant. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 04 Dec 2006 03:49:34 +0000
parents 5e07a6f8eb33
children d83f71ca0cd7
line wrap: on
line diff
--- a/libgaim/plugins/perl/common/typemap	Mon Dec 04 03:44:42 2006 +0000
+++ b/libgaim/plugins/perl/common/typemap	Mon Dec 04 03:49:34 2006 +0000
@@ -16,6 +16,7 @@
 char **					T_PTR
 gchar					T_IV
 gchar *					T_PV
+gchar_own *				T_GCHAR_OWN
 guchar					T_IV
 guchar *				T_PTR
 guchar **				T_PTR
@@ -195,3 +196,12 @@
 
 T_GaimObj
 	$arg = gaim_perl_bless_object($var, \"$type\");
+
+T_GCHAR_OWN
+	/* used when we can directly own the returned string. */
+	/* we have to copy in the case when perl's malloc != gtk's malloc,
+	 * so best copy all the time. */
+	sv_setpv ((SV*)$arg, $var);
+	SvUTF8_on ($arg);
+	g_free ($var);
+