|
From: | felix |
Subject: | Re: [Chicken-users] FFI: Safe referencing and allocation of Scheme objects from C |
Date: | Mon, 10 Nov 2003 19:44:38 +0100 |
User-agent: | Opera7.11/Linux M2 build 406 |
The calling function expects it to take an (unsigned char *), so changing the declaration causes warnings. However, I went ahead and tried changing it to: (define-external (scheme_callback_func (scheme-object x)) void (let ((p x)) (assert (procedure? p)) (p ...)))
That's better.
I also played around with the C_alloc_in_heap case a little more. The call to that function itself succeeds and returns a pointer that looks good; the fireworks start when the callback function is called. The process immediately begins spinning, using 100% CPU. I can get a print from the callback function to come through, but as soon as it tries to call the procedure passed in as x above, it goes into never-never land; not even a print at the beginning of the-procedure-x-points-to comes through. Very odd, especially since just replacing C_alloc_in_heap with malloc makes everything run happily.
The only thing that comes to mind is that either the heap-allocated object does not get passed properly, or that C_alloc_in_heap is simply buggy. I'll investigate this... cheers, felix
[Prev in Thread] | Current Thread | [Next in Thread] |