changeset 21248:5915ad785ee7

Add and call a purple_util_uninit() to free user_dir and customer_home_dir at shutdown. Fixes #3132
author Richard Laager <rlaager@wiktel.com>
date Mon, 15 Oct 2007 00:41:22 +0000
parents 93afdb7548cd
children 930d0b49ebcf e747ac0c42d6
files ChangeLog.API libpurple/core.c libpurple/util.c libpurple/util.h
diffstat 4 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Mon Oct 15 00:40:33 2007 +0000
+++ b/ChangeLog.API	Mon Oct 15 00:41:22 2007 +0000
@@ -14,6 +14,8 @@
 		  to unload a plugin--fails.  This then prevents the plugin
 		  from being saved in the saved plugins list, so it'll won't
 		  be loaded at the next startup.
+		* purple_util_init()
+		* purple_util_uninit()
 
 		* pidgin_dialogs_about_with_parent()
 		* pidgin_log_show_contact_with_parent()
--- a/libpurple/core.c	Mon Oct 15 00:40:33 2007 +0000
+++ b/libpurple/core.c	Mon Oct 15 00:41:22 2007 +0000
@@ -94,6 +94,8 @@
 	/* The signals subsystem is important and should be first. */
 	purple_signals_init();
 
+	purple_util_init();
+
 	purple_signal_register(core, "uri-handler",
 		purple_marshal_BOOLEAN__POINTER_POINTER_POINTER,
 		purple_value_new(PURPLE_TYPE_BOOLEAN), 3,
@@ -229,6 +231,9 @@
 #ifdef HAVE_DBUS
 	purple_dbus_uninit();
 #endif
+
+	purple_util_uninit();
+
 	purple_signals_uninit();
 
 	g_free(core->ui);
--- a/libpurple/util.c	Mon Oct 15 00:40:33 2007 +0000
+++ b/libpurple/util.c	Mon Oct 15 00:41:22 2007 +0000
@@ -70,6 +70,7 @@
 static char *custom_user_dir = NULL;
 static char *user_dir = NULL;
 
+
 PurpleMenuAction *
 purple_menu_action_new(const char *label, PurpleCallback callback, gpointer data,
                      GList *children)
@@ -91,6 +92,25 @@
 	g_free(act);
 }
 
+void
+purple_util_init(void)
+{
+	/* This does nothing right now.  It exists for symmetry with 
+	 * purple_util_uninit() and forwards compatibility. */
+}
+
+void
+purple_util_uninit(void)
+{
+	/* Free these so we don't have leaks at shutdown. */
+
+	g_free(custom_user_dir);
+	custom_user_dir = NULL;
+
+	g_free(user_dir);
+	user_dir = NULL;
+}
+
 /**************************************************************************
  * Base16 Functions
  **************************************************************************/
--- a/libpurple/util.h	Mon Oct 15 00:40:33 2007 +0000
+++ b/libpurple/util.h	Mon Oct 15 00:41:22 2007 +0000
@@ -86,6 +86,27 @@
 void purple_menu_action_free(PurpleMenuAction *act);
 
 /**************************************************************************/
+/** @name Utility Subsystem                                               */
+/**************************************************************************/
+/*@{*/
+
+/**
+ * Initializes the utility subsystem.
+ *
+ * @since 2.3.0
+ */
+void purple_util_init(void);
+
+/**
+ * Uninitializes the util subsystem.
+ *
+ * @since 2.3.0
+ */
+void purple_util_uninit(void);
+
+/*@}*/
+
+/**************************************************************************/
 /** @name Base16 Functions                                                */
 /**************************************************************************/
 /*@{*/