mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix r19985, r19986 for guile-1.6.8.
The return value of guile-1.6's SCM_STRING_CHARS must not be freed, as opposed to the return value of guile-1.8's scm_to_locale_string. So we must wrap the free() into a macro that is defined appropriately (or maybe we should refactor this into a function returning a g_malloc'd g_char anyway.) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19999 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ddfa713ab3
commit
6af446e0d7
@ -168,10 +168,11 @@ gnc_guile_call1_to_string(SCM func, SCM arg)
|
||||
|
||||
x = scm_to_locale_string(value);
|
||||
|
||||
/* scm_to_locale_string() returns a malloc'ed string.
|
||||
Copy to a g_malloc'ed one. */
|
||||
/* scm_to_locale_string() returns a malloc'ed string in
|
||||
guile-1.8 (but not in guile-1.6). Copy to a
|
||||
g_malloc'ed one. */
|
||||
s = g_strdup(x);
|
||||
free(x);
|
||||
gnc_free_scm_locale_string(x);
|
||||
return s;
|
||||
}
|
||||
else
|
||||
@ -675,10 +676,11 @@ gnc_split_scm_get_memo(SCM split_scm)
|
||||
|
||||
x = scm_to_locale_string(result);
|
||||
|
||||
/* scm_to_locale_string() returns a malloc'ed string.
|
||||
/* scm_to_locale_string() returns a malloc'ed string in
|
||||
guile-1.8 (but not in guile-1.6).
|
||||
Copy to a g_malloc'ed one. */
|
||||
s = g_strdup(x);
|
||||
free(x);
|
||||
gnc_free_scm_locale_string(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -708,10 +710,11 @@ gnc_split_scm_get_action(SCM split_scm)
|
||||
|
||||
x = scm_to_locale_string(result);
|
||||
|
||||
/* scm_to_locale_string() returns a malloc'ed string.
|
||||
/* scm_to_locale_string() returns a malloc'ed string in
|
||||
guile-1.8 (but not in guile-1.6).
|
||||
Copy to a g_malloc'ed one. */
|
||||
s = g_strdup(x);
|
||||
free(x);
|
||||
gnc_free_scm_locale_string(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1146,10 +1149,11 @@ gnc_get_debit_string(GNCAccountType account_type)
|
||||
|
||||
x = scm_to_locale_string(result);
|
||||
|
||||
/* scm_to_locale_string() returns a malloc'ed string.
|
||||
/* scm_to_locale_string() returns a malloc'ed string in
|
||||
guile-1.8 (but not in guile-1.6).
|
||||
Copy to a g_malloc'ed one. */
|
||||
s = g_strdup(x);
|
||||
free(x);
|
||||
gnc_free_scm_locale_string(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1186,10 +1190,11 @@ gnc_get_credit_string(GNCAccountType account_type)
|
||||
|
||||
x = scm_to_locale_string(result);
|
||||
|
||||
/* scm_to_locale_string() returns a malloc'ed string.
|
||||
/* scm_to_locale_string() returns a malloc'ed string in
|
||||
guile-1.8 (but not in guile-1.6).
|
||||
Copy to a g_malloc'ed one. */
|
||||
s = g_strdup(x);
|
||||
free(x);
|
||||
gnc_free_scm_locale_string(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ gnc_extension_path (SCM extension, char **fullpath)
|
||||
{
|
||||
strings[i] = g_strdup(gettext(s));
|
||||
}
|
||||
free(s);
|
||||
gnc_free_scm_locale_string(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -30,11 +30,22 @@
|
||||
# define scm_is_symbol SCM_SYMBOLP
|
||||
# define scm_is_true SCM_NFALSEP
|
||||
# define scm_is_vector SCM_VECTORP
|
||||
# define scm_to_locale_string SCM_STRING_CHARS
|
||||
# define scm_c_string_length SCM_STRING_LENGTH
|
||||
#elif (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 8)
|
||||
# define scm_c_string_length scm_i_string_length
|
||||
#endif
|
||||
|
||||
/* The result of SCM_STRING_CHARS must not be free'd, but the result
|
||||
* of scm_to_locale_string must. That's bad. We define the macro
|
||||
* gnc_free_scm_locale_string to wrap around free() for that
|
||||
* reason. */
|
||||
#if (SCM_MAJOR_VERSION == 1) && (SCM_MINOR_VERSION <= 6)
|
||||
# define scm_to_locale_string SCM_STRING_CHARS
|
||||
# define gnc_free_scm_locale_string (void)
|
||||
#else
|
||||
# define gnc_free_scm_locale_string free
|
||||
#endif
|
||||
|
||||
/* Convenience macros */
|
||||
|
||||
#define scm_is_equal(obj1,obj2) scm_is_true(scm_equal_p(obj1,obj2))
|
||||
|
Loading…
Reference in New Issue
Block a user