malloc-struct ( class -- struct ) (original) (raw)
malloc-struct ( class -- struct )
Factor handbook » C library interface » Struct classes » Creating instances of structs
Prev: | ( class -- quot: ( ... -- struct ) ) |
---|---|
Next: | memory>struct ( ptr class -- struct ) |
Inputs
class | a class |
---|
Outputs
struct | a struct |
---|
Word description
Allocates unmanaged C heap memory for a new struct of the specified class. The new struct's slots are initialized to their initial values. The struct should be freed when it is no longer needed.
See also
, , memory>struct
Definition
USING: alien alien.c-types alien.data classes.struct.private
kernel libc ;
: malloc-struct ( class -- struct )
[ >c-ptr malloc-byte-array ] [ 1 swap heap-size calloc ]
init-struct ; inline