From: <dat...@us...> - 2006-12-04 03:49:35
|
Revision: 17889 http://svn.sourceforge.net/gaim/?rev=17889&view=rev Author: datallah Date: 2006-12-03 19:49:34 -0800 (Sun, 03 Dec 2006) Log Message: ----------- 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. Modified Paths: -------------- trunk/gtk/gtksound.c trunk/gtk/gtksound.h trunk/gtk/plugins/perl/common/GtkIMHtml.xs trunk/gtk/plugins/perl/common/GtkSound.xs trunk/gtk/plugins/perl/common/GtkStatusBox.xs trunk/gtk/plugins/perl/common/GtkUtils.xs trunk/libgaim/plugins/perl/common/Log.xs trunk/libgaim/plugins/perl/common/Util.xs trunk/libgaim/plugins/perl/common/XMLNode.xs trunk/libgaim/plugins/perl/common/module.h trunk/libgaim/plugins/perl/common/typemap Modified: trunk/gtk/gtksound.c =================================================================== --- trunk/gtk/gtksound.c 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/gtksound.c 2006-12-04 03:49:34 UTC (rev 17889) @@ -242,7 +242,7 @@ return sounds[event].pref; } -char * +const char * gaim_gtk_sound_get_event_label(GaimSoundEventID event) { if(event >= GAIM_NUM_SOUNDS) Modified: trunk/gtk/gtksound.h =================================================================== --- trunk/gtk/gtksound.h 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/gtksound.h 2006-12-04 03:49:34 UTC (rev 17889) @@ -46,7 +46,7 @@ * @param event The event. * @return The label. */ -char *gaim_gtk_sound_get_event_label(GaimSoundEventID event); +const char *gaim_gtk_sound_get_event_label(GaimSoundEventID event); /** * Gets GTK+ sound UI ops. Modified: trunk/gtk/plugins/perl/common/GtkIMHtml.xs =================================================================== --- trunk/gtk/plugins/perl/common/GtkIMHtml.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/plugins/perl/common/GtkIMHtml.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -60,7 +60,7 @@ /* This can't work at the moment since I don't have a typemap for Gtk::Widget. * I thought about using the one from libgtk2-perl but wasn't sure how to go * about doing that. -char * +gchar_own * gtk_imhtml_get_markup_range(imhtml, start, end) Gaim::GtkUI::IMHtml imhtml Gtk::TextIter start @@ -70,7 +70,7 @@ /* This can't work at the moment since I don't have a typemap for Gtk::Widget. * I thought about using the one from libgtk2-perl but wasn't sure how to go * about doing that. -char * +gchar_own * gtk_imhtml_get_text(imhtml, start, end) Gaim::GtkUI::IMHtml imhtml Gtk::TextIter start @@ -215,19 +215,19 @@ gtk_imhtml_get_format_functions(imhtml) Gaim::GtkUI::IMHtml imhtml -char * +gchar_own * gtk_imhtml_get_current_fontface(imhtml) Gaim::GtkUI::IMHtml imhtml -char * +gchar_own * gtk_imhtml_get_current_forecolor(imhtml) Gaim::GtkUI::IMHtml imhtml -char * +gchar_own * gtk_imhtml_get_current_backcolor(imhtml) Gaim::GtkUI::IMHtml imhtml -char * +gchar_own * gtk_imhtml_get_current_background(imhtml) Gaim::GtkUI::IMHtml imhtml @@ -303,7 +303,7 @@ gtk_imhtml_font_grow(imhtml) Gaim::GtkUI::IMHtml imhtml -char * +gchar_own * gtk_imhtml_get_markup(imhtml) Gaim::GtkUI::IMHtml imhtml Modified: trunk/gtk/plugins/perl/common/GtkSound.xs =================================================================== --- trunk/gtk/plugins/perl/common/GtkSound.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/plugins/perl/common/GtkSound.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -7,7 +7,7 @@ gaim_gtk_sound_get_event_option(event) Gaim::SoundEventID event -char * +const char * gaim_gtk_sound_get_event_label(event) Gaim::SoundEventID event Modified: trunk/gtk/plugins/perl/common/GtkStatusBox.xs =================================================================== --- trunk/gtk/plugins/perl/common/GtkStatusBox.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/plugins/perl/common/GtkStatusBox.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -45,6 +45,6 @@ gtk_gaim_status_box_get_buddy_icon(status_box) Gaim::GtkUI::StatusBox status_box -char * +gchar_own * gtk_gaim_status_box_get_message(status_box) Gaim::GtkUI::StatusBox status_box Modified: trunk/gtk/plugins/perl/common/GtkUtils.xs =================================================================== --- trunk/gtk/plugins/perl/common/GtkUtils.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/gtk/plugins/perl/common/GtkUtils.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -10,7 +10,7 @@ void gaim_gtk_load_accels() -char * +gchar_own * gaim_gtk_convert_buddy_icon(plugin, path) Gaim::Plugin plugin const char * path Modified: trunk/libgaim/plugins/perl/common/Log.xs =================================================================== --- trunk/libgaim/plugins/perl/common/Log.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/libgaim/plugins/perl/common/Log.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -21,7 +21,7 @@ gaim_log_free(log) Gaim::Log log -char * +gchar_own * gaim_log_get_log_dir(type, name, account) Gaim::LogType type const char *name @@ -83,7 +83,7 @@ XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry"))); } -char * +gchar_own * gaim_log_read(log, flags) Gaim::Log log Gaim::Log::ReadFlags flags Modified: trunk/libgaim/plugins/perl/common/Util.xs =================================================================== --- trunk/libgaim/plugins/perl/common/Util.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/libgaim/plugins/perl/common/Util.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -74,7 +74,7 @@ gaim_escape_filename(str) const char *str -char * +gchar_own * gaim_fd_get_ip(fd) int fd @@ -104,7 +104,7 @@ const char **end GData **attributes -char * +gchar_own * gaim_markup_get_tag_name(tag) const char *tag @@ -114,17 +114,17 @@ char **dest_xhtml char **dest_plain -char * +gchar_own * gaim_markup_linkify(str) const char *str -char * +gchar_own * gaim_markup_slice(str, x, y) const char *str guint x guint y -char * +gchar_own * gaim_markup_strip_html(str) const char *str @@ -147,11 +147,11 @@ gaim_program_is_valid(program) const char *program -char * +gchar_own * gaim_str_add_cr(str) const char *str -char * +gchar_own * gaim_str_binary_to_ascii(binary, len) const unsigned char *binary guint len @@ -166,11 +166,11 @@ const char *s const char *x -char * +gchar_own * gaim_str_seconds_to_string(sec) guint sec -char * +gchar_own * gaim_str_size_to_units(size) size_t size @@ -187,7 +187,7 @@ long *tz_off const char **rest -gchar * +gchar_own * gaim_strcasereplace(string, delimiter, replacement) const char *string const char *delimiter @@ -198,17 +198,17 @@ const char *haystack const char *needle -gchar * +gchar_own * gaim_strdup_withhtml(src) const gchar *src -gchar * +gchar_own * gaim_strreplace(string, delimiter, replacement) const char *string const char *delimiter const char *replacement -char * +gchar_own * gaim_text_strip_mnemonic(in) const char *in @@ -229,7 +229,7 @@ gaim_unescape_filename(str) const char *str -char * +gchar_own * gaim_unescape_html(html) const char *html Modified: trunk/libgaim/plugins/perl/common/XMLNode.xs =================================================================== --- trunk/libgaim/plugins/perl/common/XMLNode.xs 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/libgaim/plugins/perl/common/XMLNode.xs 2006-12-04 03:49:34 UTC (rev 17889) @@ -36,7 +36,7 @@ const char *name const char *xmlns -char * +gchar_own * xmlnode_get_data(node) Gaim::XMLNode node @@ -77,12 +77,12 @@ const char *attr const char *value -char * +gchar_own * xmlnode_to_formatted_str(node, len) Gaim::XMLNode node int *len -char * +gchar_own * xmlnode_to_str(node, len) Gaim::XMLNode node int *len Modified: trunk/libgaim/plugins/perl/common/module.h =================================================================== --- trunk/libgaim/plugins/perl/common/module.h 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/libgaim/plugins/perl/common/module.h 2006-12-04 03:49:34 UTC (rev 17889) @@ -271,3 +271,6 @@ /* other */ typedef void * Gaim__Handle; + +typedef gchar gchar_own; + Modified: trunk/libgaim/plugins/perl/common/typemap =================================================================== --- trunk/libgaim/plugins/perl/common/typemap 2006-12-04 03:44:42 UTC (rev 17888) +++ trunk/libgaim/plugins/perl/common/typemap 2006-12-04 03:49:34 UTC (rev 17889) @@ -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); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |