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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17058 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2008-03-29 01:20:01 +00:00
parent 15d086d178
commit 733d0dfe70
5 changed files with 14 additions and 1 deletions

View File

@ -283,6 +283,7 @@ qsf_session_end( QofBackend *be)
static void
qsf_destroy_backend (QofBackend *be)
{
qof_backend_destroy(be);
g_free(be);
}

View File

@ -377,6 +377,7 @@ void qof_backend_set_message(QofBackend *be, const char *format, ...);
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

View File

@ -144,6 +144,15 @@ qof_backend_init(QofBackend *be)
be->export = NULL;
}
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)
{

View File

@ -128,7 +128,8 @@ void
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)
{

View File

@ -320,6 +320,7 @@ file_session_end(QofBackend *be_start)
static void
file_destroy_backend(QofBackend *be)
{
qof_backend_destroy(be);
g_free(be);
}