/soc/2013/ankitkv/gobjectification: 2ccd829171ec: Renamed purple...

Ankit Vani a at nevitus.org
Thu Aug 1 07:11:34 EDT 2013


Changeset: 2ccd829171ece7f572fa0d8afb2f82bcf9b809a7
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-01 16:17 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/2ccd829171ec

Description:

Renamed purple_plugins_get_all() to purple_plugins_find_all() since the list is generated.
Also added purple_plugins_free_found_list() to free this list when done with it.

diffstat:

 libpurple/plugins.c |  17 ++++++++++++++---
 libpurple/plugins.h |  12 ++++++++++--
 2 files changed, 24 insertions(+), 5 deletions(-)

diffs (72 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -351,7 +351,7 @@ purple_plugin_action_get_type(void)
  * Plugins API
  **************************************************************************/
 GList *
-purple_plugins_get_all(void)
+purple_plugins_find_all(void)
 {
 	GList *ret = NULL, *ids, *l;
 	GSList *plugins, *ll;
@@ -361,7 +361,7 @@ purple_plugins_get_all(void)
 	for (l = ids; l; l = l->next) {
 		plugins = gplugin_plugin_manager_find_plugins(l->data);
 		for (ll = plugins; ll; ll = ll->next)
-			ret = g_list_append(ret, GPLUGIN_PLUGIN(ll->data));
+			ret = g_list_append(ret, g_object_ref(ll->data));
 
 		gplugin_plugin_manager_free_plugin_list(plugins);
 	}
@@ -370,6 +370,17 @@ purple_plugins_get_all(void)
 	return ret;
 }
 
+void
+purple_plugins_free_found_list(GList *plugins)
+{
+	GList *l;
+
+	for (l = plugins; l != NULL; l = l->next)
+		g_object_unref(l->data);
+
+	g_list_free(plugins);
+}
+
 GList *
 purple_plugins_get_loaded(void)
 {
@@ -385,7 +396,7 @@ purple_plugins_find_by_filename(const ch
 		GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data);
 
 		if (purple_strequal(gplugin_plugin_get_filename(plugin), filename))
-			return plugin;
+			return g_object_ref(plugin);
 	}
 
 	return NULL;
diff --git a/libpurple/plugins.h b/libpurple/plugins.h
--- a/libpurple/plugins.h
+++ b/libpurple/plugins.h
@@ -208,10 +208,18 @@ GType purple_plugin_action_get_type(void
 
 /**
  * Returns a list of all plugins, whether loaded or not.
+ * Use purple_plugins_free_found_list() to free this list when done with it.
  *
- * @constreturn A list of all plugins.
+ * @return A list of all referenced plugins.
  */
-GList *purple_plugins_get_all(void);
+GList *purple_plugins_find_all(void);
+
+/**
+ * Frees a list of referenced plugins by unreferencing them first.
+ *
+ * @param plugins The list of referenced plugins.
+ */
+void purple_plugins_free_found_list(GList *plugins);
 
 /**
  * Returns a list of all loaded plugins.



More information about the Commits mailing list