mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MIT-Scheme-devel] [PATCH] FFI: Fixing problem with groveller for st


From: Matt Birkholz
Subject: Re: [MIT-Scheme-devel] [PATCH] FFI: Fixing problem with groveller for structures with typedefs.
Date: Wed, 12 Dec 2012 14:19:09 -0700

> From: Peter Feigl <address@hidden>
> Date: Wed, 12 Dec 2012 20:26:31 +0100
> 
> [...]
> 
> I've been playing around with the shim C code, is there a way I can
> create an alien that contains a struct?

No.  Aliens are extra-heap pointers.  You CAN create an alien
containing the memory address of a struct -- a pointer to a struct.
The address should be outside the heap, in memory that you or your
library allocated.

> Then it should be possible to support structs as return and
> parameter types.

There are multitudinous ways to support structs as return and
parameter types, all of them sad and boring.

> Are aliens garbage-collected automatically?

Sometimes.

> Can I just malloc some memory for an alien, then cons_alien it, then
> expect it to be garbage-collected later?

Nope.  You CAN use the Scheme procedure malloc to allocate some memory
that will be free()d if the returned alien is ever garbage collected.
(This is in the manual, yes?)

cons_alien is a callback trampoline utility.  It will occasionally
abort.  The shim callback code is prepared to re-start after a GC
abort, so... don't "play around" with the shim code (unless you
understand what I just wrote).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]