Guile Strings
John Ralls
jralls at ceridwen.us
Fri Dec 30 18:18:30 EST 2011
On Dec 30, 2011, at 9:19 AM, Geert Janssens wrote:
> Op vrijdag 30 december 2011 09:06:58 schreef u:
>> On Dec 30, 2011, at 2:57 AM, Geert Janssens wrote:
>> As for the string problem, we may have to modify the C-side functions to
>> require gstrdup'd strings that the consumer function frees. I'll have to
>> have a look at how those strings are being used to suggest something more
>> concrete.
>>
The actual code that SWIG injects is
SWIGINTERN char *
SWIG_Guile_scm2newstr(SCM str, size_t *len) {
#define FUNC_NAME "SWIG_Guile_scm2newstr"
char *ret;
size_t l;
SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME);
l = SCM_STRING_LENGTH(str);
ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
if (!ret) return NULL;
memcpy(ret, SCM_STRING_CHARS(str), l);
ret[l] = '\0';
if (len) *len = l;
return ret;
#undef FUNC_NAME
}
As you can see, it's allocating a string on the heap and returning it, so either the strings are already getting freed or we're already leaking them.
So I went ahead and built swig with the patch from the bug and gave it a spin. It did indeed silence the deprecation warnings in guile-1.8.8.
Unfortunately guile-2.0 appears to have changed the way that extensions are loaded, because with guile-2.0 installed make check fails with
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /Volumes/RAID1/Gnucash-Build/Gnucash-svn/src/gnucash-git/src/engine/test/./test-create-account.scm
;;; note: source file /Volumes/RAID1/Gnucash-Build/Gnucash-svn/src/gnucash-git/src/gnc-module/gnc-module.scm
;;; newer than compiled /Users/john/.cache/guile/ccache/2.0-LE-4-2.0/Volumes/RAID1/Gnucash-Build/Gnucash-svn/src/gnucash-git/src/gnc-module/gnc-module.scm.go
;;; compiling /Volumes/RAID1/Gnucash-Build/Gnucash-svn/src/gnucash-git/src/gnc-module/gnc-module.scm
;;; WARNING: compilation of /Volumes/RAID1/Gnucash-Build/Gnucash-svn/src/gnucash-git/src/gnc-module/gnc-module.scm failed:
;;; ERROR: no code for module (sw_gnc_module)
./test-create-account: line 2: 80147 Bus error guile -l $SRCDIR/test-create-account.scm -c "(exit (run-test))"
I poked at it briefly, but it couldn't get it to work.
Regards,
John Ralls
More information about the gnucash-devel
mailing list