qulogic/gplugin

Use g_clear_pointer in finalize methods.
feature/new-glib-stuff
2019-01-24, Elliott Sales de Andrade
5f50e5512a85
Parents 2d1b124d8a70
Children 6067f6b7ecb0
Use g_clear_pointer in finalize methods.
--- a/gplugin/gplugin-manager.c Thu Jan 24 18:44:25 2019 -0500
+++ b/gplugin/gplugin-manager.c Thu Jan 24 19:13:45 2019 -0500
@@ -890,21 +890,22 @@
GPluginManager *manager = GPLUGIN_MANAGER(obj);
g_queue_free_full(manager->paths, g_free);
+ manager->paths = NULL;
/* free all the data in the plugins hash table and destroy it */
g_hash_table_foreach_remove(manager->plugins,
gplugin_manager_remove_list_value,
NULL);
- g_hash_table_destroy(manager->plugins);
+ g_clear_pointer(&manager->plugins, g_hash_table_destroy);
/* destroy the filename view */
- g_hash_table_destroy(manager->plugins_filename_view);
+ g_clear_pointer(&manager->plugins_filename_view, g_hash_table_destroy);
/* free all the data in the loaders hash table and destroy it */
g_hash_table_foreach_remove(manager->loaders,
gplugin_manager_remove_list_value,
NULL);
- g_hash_table_destroy(manager->loaders);
+ g_clear_pointer(&manager->loaders, g_hash_table_destroy);
/* call the base class's destructor */
G_OBJECT_CLASS(gplugin_manager_parent_class)->finalize(obj);
--- a/gplugin/gplugin-native-plugin.c Thu Jan 24 18:44:25 2019 -0500
+++ b/gplugin/gplugin-native-plugin.c Thu Jan 24 19:13:45 2019 -0500
@@ -177,7 +177,7 @@
gplugin_native_plugin_finalize(GObject *obj) {
GPluginNativePluginPrivate *priv = gplugin_native_plugin_get_instance_private(GPLUGIN_NATIVE_PLUGIN(obj));
- g_free(priv->filename);
+ g_clear_pointer(&priv->filename, g_free);
g_clear_object(&priv->loader);
g_clear_object(&priv->info);
--- a/gplugin/gplugin-plugin-info.c Thu Jan 24 18:44:25 2019 -0500
+++ b/gplugin/gplugin-plugin-info.c Thu Jan 24 19:13:45 2019 -0500
@@ -435,19 +435,19 @@
gplugin_plugin_info_finalize(GObject *obj) {
GPluginPluginInfoPrivate *priv = gplugin_plugin_info_get_instance_private(GPLUGIN_PLUGIN_INFO(obj));
- g_free(priv->id);
- g_free(priv->name);
- g_free(priv->version);
- g_free(priv->license_id);
- g_free(priv->license_text);
- g_free(priv->license_url);
- g_free(priv->icon);
- g_free(priv->summary);
- g_free(priv->description);
- g_strfreev(priv->authors);
- g_free(priv->help);
- g_free(priv->website);
- g_strfreev(priv->dependencies);
+ g_clear_pointer(&priv->id, g_free);
+ g_clear_pointer(&priv->name, g_free);
+ g_clear_pointer(&priv->version, g_free);
+ g_clear_pointer(&priv->license_id, g_free);
+ g_clear_pointer(&priv->license_text, g_free);
+ g_clear_pointer(&priv->license_url, g_free);
+ g_clear_pointer(&priv->icon, g_free);
+ g_clear_pointer(&priv->summary, g_free);
+ g_clear_pointer(&priv->description, g_free);
+ g_clear_pointer(&priv->authors, g_strfreev);
+ g_clear_pointer(&priv->help, g_free);
+ g_clear_pointer(&priv->website, g_free);
+ g_clear_pointer(&priv->dependencies, g_strfreev);
G_OBJECT_CLASS(gplugin_plugin_info_parent_class)->finalize(obj);
}
--- a/lua/gplugin-lua-plugin.c Thu Jan 24 18:44:25 2019 -0500
+++ b/lua/gplugin-lua-plugin.c Thu Jan 24 19:13:45 2019 -0500
@@ -136,10 +136,8 @@
gplugin_lua_plugin_finalize(GObject *obj) {
GPluginLuaPluginPrivate *priv = gplugin_lua_plugin_get_instance_private(GPLUGIN_LUA_PLUGIN(obj));
- if(priv->L)
- lua_close(priv->L);
-
- g_free(priv->filename);
+ g_clear_pointer(&priv->L, lua_close);
+ g_clear_pointer(&priv->filename, g_free);
g_clear_object(&priv->loader);
g_clear_object(&priv->info);
--- a/python/gplugin-python-plugin.c Thu Jan 24 18:44:25 2019 -0500
+++ b/python/gplugin-python-plugin.c Thu Jan 24 19:13:45 2019 -0500
@@ -263,7 +263,7 @@
if(priv->unload)
Py_DECREF(priv->unload);
- g_free(priv->filename);
+ g_clear_pointer(&priv->filename, g_free);
g_clear_object(&priv->loader);
g_clear_object(&priv->info);
--- a/tcc/gplugin-tcc-plugin.c Thu Jan 24 18:44:25 2019 -0500
+++ b/tcc/gplugin-tcc-plugin.c Thu Jan 24 19:13:45 2019 -0500
@@ -106,11 +106,8 @@
gplugin_tcc_plugin_finalize(GObject *obj) {
GPluginTccPluginPrivate *priv = GPLUGIN_TCC_PLUGIN_GET_PRIVATE(obj);
- if(priv->s)
- tcc_delete(priv->s);
-
- if(priv->mem)
- g_free(priv->mem);
+ g_clear_pointer(&priv->s, tcc_delete);
+ g_clear_pointer(&priv->mem);
G_OBJECT_CLASS(parent_class)->finalize(obj);
}