r17058 - gnucash/trunk - Fix two memory leaks in QOF. Add qof_backend_destroy().
Andreas Köhler
andi5 at cvs.gnucash.org
Fri Mar 28 21:20:02 EDT 2008
Author: andi5
Date: 2008-03-28 21:20:01 -0400 (Fri, 28 Mar 2008)
New Revision: 17058
Trac: http://svn.gnucash.org/trac/changeset/17058
Modified:
gnucash/trunk/lib/libqof/backend/file/qsf-backend.c
gnucash/trunk/lib/libqof/qof/qofbackend-p.h
gnucash/trunk/lib/libqof/qof/qofbackend.c
gnucash/trunk/lib/libqof/qof/qoflog.c
gnucash/trunk/src/backend/file/gnc-backend-file.c
Log:
Fix two memory leaks in QOF. Add qof_backend_destroy().
Backends should call this function to make sure they free the kvp frame
for the backend configuration.
Modified: gnucash/trunk/lib/libqof/backend/file/qsf-backend.c
===================================================================
--- gnucash/trunk/lib/libqof/backend/file/qsf-backend.c 2008-03-27 23:39:57 UTC (rev 17057)
+++ gnucash/trunk/lib/libqof/backend/file/qsf-backend.c 2008-03-29 01:20:01 UTC (rev 17058)
@@ -283,6 +283,7 @@
static void
qsf_destroy_backend (QofBackend *be)
{
+ qof_backend_destroy(be);
g_free(be);
}
Modified: gnucash/trunk/lib/libqof/qof/qofbackend-p.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend-p.h 2008-03-27 23:39:57 UTC (rev 17057)
+++ gnucash/trunk/lib/libqof/qof/qofbackend-p.h 2008-03-29 01:20:01 UTC (rev 17058)
@@ -377,6 +377,7 @@
char * qof_backend_get_message(QofBackend *be);
void qof_backend_init(QofBackend *be);
+void qof_backend_destroy(QofBackend *be);
/** Allow backends to see if the book is open
Modified: gnucash/trunk/lib/libqof/qof/qofbackend.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend.c 2008-03-27 23:39:57 UTC (rev 17057)
+++ gnucash/trunk/lib/libqof/qof/qofbackend.c 2008-03-29 01:20:01 UTC (rev 17058)
@@ -145,6 +145,15 @@
}
void
+qof_backend_destroy(QofBackend *be)
+{
+ g_free(be->error_msg);
+ be->error_msg = NULL;
+ kvp_frame_delete(be->backend_configuration);
+ be->backend_configuration = NULL;
+}
+
+void
qof_backend_run_begin(QofBackend *be, QofInstance *inst)
{
if(!be || !inst) { return; }
Modified: gnucash/trunk/lib/libqof/qof/qoflog.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.c 2008-03-27 23:39:57 UTC (rev 17057)
+++ gnucash/trunk/lib/libqof/qof/qoflog.c 2008-03-29 01:20:01 UTC (rev 17058)
@@ -128,7 +128,8 @@
qof_log_init_filename(const gchar* log_filename)
{
if (log_table == NULL)
- log_table = g_hash_table_new(g_str_hash, g_str_equal);
+ log_table = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
if (log_filename)
{
Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c 2008-03-27 23:39:57 UTC (rev 17057)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c 2008-03-29 01:20:01 UTC (rev 17058)
@@ -320,6 +320,7 @@
static void
file_destroy_backend(QofBackend *be)
{
+ qof_backend_destroy(be);
g_free(be);
}
More information about the gnucash-changes
mailing list