[plt-scheme] Make uninitialized cstruct

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jun 16 13:40:55 EDT 2005

On Jun 17, Chihiro Kuraya wrote:
> I want to make large cstruct by not initializing its fields.
> define-cstruct syntax provides make-TYPE function, but it is always
> required to specify initial values of all fields.
> 
> This is very cumbersome in the case structure is used only for
> retrieving information by forign function (for eaxample,
> GetStartupInfo Windows API).
> 
> Are there any way to make uninitialized cstruct or
> zero-initialized cstruct ?

Yes, but you'll need to work a bit under the struct hood.  You can use
(malloc _your-struct) and then use set-cpointer-tag! and
your-struct-tag with the result.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



Posted on the users mailing list.