[plt-scheme] ffi equivalent of array in struct

From: Jon Rafkind (workmin at ccs.neu.edu)
Date: Mon Apr 24 23:30:25 EDT 2006

>Like I said, if you know that it's 64K bytes, then just use malloc
>with the number.  It would be nice to just create new types manually,
>given a size and an alignment, but libffi doesn't allow that, and
>creating such huge type descriptors is going to be a problem.
>
>  
>
Ok, but someone may have to define a struct, not just a chunk of memory, 
where one of the members is a chunk and at that point they would have to 
use make-cstruct for the chunk and regular types for the members:
struct{
  int x, y, z;
  char a, b, c;
  char stuff[ 1000 ];
}

(define 1000bytes (make-c-struct (list-of 1000 _byte))
(define-cstruct (x _int) (y _int) ... (stuff _1000bytes))

Anyway, for my specific problem I just need a chunk of memory so malloc 
is good enough.




Posted on the users mailing list.