Fix memory leaks found with valgrind

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20739 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
J. Alex Aycinena 2011-06-08 16:46:32 +00:00
parent f77309616d
commit 60aa509039
3 changed files with 40 additions and 6 deletions

View File

@ -150,10 +150,16 @@ update_display_lists(gnc_column_view_edit * view)
{ {
for (i = 0; !scm_is_null(names); names = SCM_CDR(names), i++) for (i = 0; !scm_is_null(names); names = SCM_CDR(names), i++)
{ {
char * str;
if (scm_is_equal (SCM_CAR(names), selection)) if (scm_is_equal (SCM_CAR(names), selection))
row = i; row = i;
name = _(scm_to_locale_string(scm_call_2(template_menu_name, SCM_CAR(names), scm_dynwind_begin (0);
SCM_BOOL_F))); str = scm_to_locale_string (scm_call_2(template_menu_name, SCM_CAR(names),
SCM_BOOL_F));
name = _(g_strdup (str));
scm_dynwind_free (str);
scm_dynwind_end ();
gtk_list_store_append(store, &iter); gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, gtk_list_store_set(store, &iter,
AVAILABLE_COL_NAME, name, AVAILABLE_COL_NAME, name,
@ -192,12 +198,18 @@ update_display_lists(gnc_column_view_edit * view)
{ {
for (i = 0; !scm_is_null(contents); contents = SCM_CDR(contents), i++) for (i = 0; !scm_is_null(contents); contents = SCM_CDR(contents), i++)
{ {
char * str;
if (scm_is_equal (SCM_CAR(contents), selection)) if (scm_is_equal (SCM_CAR(contents), selection))
row = i; row = i;
id = scm_num2int(SCM_CAAR(contents), SCM_ARG1, G_STRFUNC); id = scm_num2int(SCM_CAAR(contents), SCM_ARG1, G_STRFUNC);
this_report = gnc_report_find(id); this_report = gnc_report_find(id);
name = _(scm_to_locale_string(scm_call_1(report_menu_name, this_report))); scm_dynwind_begin (0);
str = scm_to_locale_string (scm_call_1(report_menu_name, this_report));
name = _(g_strdup (str));
scm_dynwind_free (str);
scm_dynwind_end ();
gtk_list_store_append(store, &iter); gtk_list_store_append(store, &iter);
gtk_list_store_set gtk_list_store_set

View File

@ -199,8 +199,15 @@ gnc_style_sheet_new (StyleSheetDialog * ssd)
/* put in the list of style sheet type names */ /* put in the list of style sheet type names */
for (; !scm_is_null(templates); templates = SCM_CDR(templates)) for (; !scm_is_null(templates); templates = SCM_CDR(templates))
{ {
char * str;
const char* orig_name;
SCM t = SCM_CAR(templates); SCM t = SCM_CAR(templates);
const char* orig_name = scm_to_locale_string(scm_call_1(t_name, t)); scm_dynwind_begin (0);
str = scm_to_locale_string (scm_call_1(t_name, t));
orig_name = g_strdup (str);
scm_dynwind_free (str);
scm_dynwind_end ();
/* Store the untranslated names for lookup later */ /* Store the untranslated names for lookup later */
template_names = g_list_prepend (template_names, (gpointer)orig_name); template_names = g_list_prepend (template_names, (gpointer)orig_name);
@ -251,12 +258,17 @@ gnc_style_sheet_select_dialog_add_one(StyleSheetDialog * ss,
{ {
SCM get_name, scm_name; SCM get_name, scm_name;
const gchar *c_name; const gchar *c_name;
char * str;
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreeIter iter; GtkTreeIter iter;
get_name = scm_c_eval_string("gnc:html-style-sheet-name"); get_name = scm_c_eval_string("gnc:html-style-sheet-name");
scm_name = scm_call_1(get_name, sheet_info); scm_name = scm_call_1(get_name, sheet_info);
c_name = scm_to_locale_string(scm_name); scm_dynwind_begin (0);
str = scm_to_locale_string (scm_name);
c_name = g_strdup (str);
scm_dynwind_free (str);
scm_dynwind_end ();
if (!c_name) if (!c_name)
return; return;

View File

@ -159,13 +159,23 @@ gnc_report_window_default_params_editor(SCM options, SCM report)
{ {
ptr = scm_call_1(get_template_name, ptr); ptr = scm_call_1(get_template_name, ptr);
if (scm_is_string(ptr)) if (scm_is_string(ptr))
title = scm_to_locale_string(ptr); {
char * str;
scm_dynwind_begin (0);
str = scm_to_locale_string (ptr);
title = g_strdup (str);
scm_dynwind_free (str);
scm_dynwind_end ();
}
} }
} }
/* Don't forget to translate the window title */ /* Don't forget to translate the window title */
prm->win = gnc_options_dialog_new((gchar*) (title && *title ? _(title) : "")); prm->win = gnc_options_dialog_new((gchar*) (title && *title ? _(title) : ""));
g_free ((gpointer *) title);
scm_gc_protect_object(prm->scm_options); scm_gc_protect_object(prm->scm_options);
scm_gc_protect_object(prm->cur_report); scm_gc_protect_object(prm->cur_report);