(malloc-struct) ( class -- struct ) (original) (raw)

(malloc-struct) ( class -- struct )
Factor handbook » C library interface » Struct classes » Creating instances of structs

Prev: (struct) ( class -- struct )
Next: S{

Vocabulary
classes.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 left uninitialized; to initialize the allocated memory with the slots' initial values, use malloc-struct. The struct should be freed when it is no longer needed.

See also
(struct)

Definition

USING: alien.c-types kernel libc ;

IN: classes.struct

: (malloc-struct) ( class -- struct )
[ heap-size malloc ] keep memory>struct ; inline