[goffice] Conf: more ref_count trouble.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Conf: more ref_count trouble.
- Date: Sun, 28 Oct 2012 22:07:54 +0000 (UTC)
commit e1bd883c8d1914e2a341c16817f7b76d07131397
Author: Morten Welinder <terra gnome org>
Date: Sun Oct 28 18:07:16 2012 -0400
Conf: more ref_count trouble.
goffice/app/go-conf-keyfile.c | 15 +++++++++++----
goffice/app/go-conf-win32.c | 17 ++++++++++++-----
2 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/goffice/app/go-conf-keyfile.c b/goffice/app/go-conf-keyfile.c
index 893d16d..361c879 100644
--- a/goffice/app/go-conf-keyfile.c
+++ b/goffice/app/go-conf-keyfile.c
@@ -144,10 +144,17 @@ go_conf_get_node (GOConfNode *parent, gchar const *key)
void
go_conf_free_node (GOConfNode *node)
{
- if (node != NULL && node->ref_count-- > 1) {
- g_free (node->path);
- g_free (node);
- }
+ if (!node)
+ return;
+
+ g_return_if_fail (node->ref_count > 0);
+
+ node->ref_count--;
+ if (node->ref_count > 0)
+ return;
+
+ g_free (node->path);
+ g_free (node);
}
void
diff --git a/goffice/app/go-conf-win32.c b/goffice/app/go-conf-win32.c
index 92a79e5..dcc3086 100644
--- a/goffice/app/go-conf-win32.c
+++ b/goffice/app/go-conf-win32.c
@@ -288,11 +288,18 @@ go_conf_get_node (GOConfNode *parent, const gchar *key)
void
go_conf_free_node (GOConfNode *node)
{
- if (node && node->ref_count-- > 1) {
- RegCloseKey (node->hKey);
- g_free (node->path);
- g_free (node);
- }
+ if (!node)
+ return;
+
+ g_return_if_fail (node->ref_count > 0);
+
+ node->ref_count--;
+ if (node->ref_count > 0)
+ return;
+
+ RegCloseKey (node->hKey);
+ g_free (node->path);
+ g_free (node);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]