r19999 - gnucash/trunk/src - Fix r19985, r19986 for guile-1.6.8.
Christian Stimming
cstim at code.gnucash.org
Thu Dec 30 06:33:31 EST 2010
Author: cstim
Date: 2010-12-30 06:33:31 -0500 (Thu, 30 Dec 2010)
New Revision: 19999
Trac: http://svn.gnucash.org/trac/changeset/19999
Modified:
gnucash/trunk/src/app-utils/guile-util.c
gnucash/trunk/src/gnome-utils/gnc-menu-extensions.c
gnucash/trunk/src/guile-mappings.h
Log:
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.)
Modified: gnucash/trunk/src/app-utils/guile-util.c
===================================================================
--- gnucash/trunk/src/app-utils/guile-util.c 2010-12-30 11:02:13 UTC (rev 19998)
+++ gnucash/trunk/src/app-utils/guile-util.c 2010-12-30 11:33:31 UTC (rev 19999)
@@ -168,10 +168,11 @@
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 @@
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 @@
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 @@
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 @@
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;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-menu-extensions.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-menu-extensions.c 2010-12-30 11:02:13 UTC (rev 19998)
+++ gnucash/trunk/src/gnome-utils/gnc-menu-extensions.c 2010-12-30 11:33:31 UTC (rev 19999)
@@ -184,7 +184,7 @@
{
strings[i] = g_strdup(gettext(s));
}
- free(s);
+ gnc_free_scm_locale_string(s);
}
else
{
Modified: gnucash/trunk/src/guile-mappings.h
===================================================================
--- gnucash/trunk/src/guile-mappings.h 2010-12-30 11:02:13 UTC (rev 19998)
+++ gnucash/trunk/src/guile-mappings.h 2010-12-30 11:33:31 UTC (rev 19999)
@@ -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))
More information about the gnucash-changes
mailing list