|
From: | Levi Pearson |
Subject: | [Chicken-users] FFI with callbacks for gnu readline |
Date: | Wed, 18 Jan 2006 15:25:05 -0700 |
The readline library expects to be able to call a generator function with a string and an index and get back a newly-allocated string that it can use and then free(). To accommodate this, I wrote a C function that calls a define-external'd scheme function that returns a scheme-object containing the string. I found that returning a c- string would sometimes give me some garbage characters as the strings were not always null-terminated at the right spot. The C function gets the string length and c-string pointer out of the scheme-object, makes a newly-allocated copy, and passes it back to readline.
This all seems to work well, but after a bit of use of the tab- completion functionality, the program segfaults or otherwise dies on a call to the readline interface. I've packaged up a pretty minimal test case, which can be downloaded from http://lifeoflevi.com/ crasher.tar.gz
I'd appreciate any help I can get, as this problem has been haunting me for a couple of days now.
--Levi
[Prev in Thread] | Current Thread | [Next in Thread] |