Handbook
Glossary
malloc-struct ( class -- struct )
Factor handbook
»
C library interface
»
Struct classes
»
Creating instances of structs
Prev:
<struct-boa> ( class -- quot: ( ... -- struct ) )
Next:
memory>struct ( ptr class -- struct )
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 initialized to their initial values. The struct should be
free
d when it is no longer needed.
See also
<struct>
,
<struct-boa>
,
memory>struct
Definition
USING:
alien
alien.c-types
alien.data
classes.struct.private
kernel
libc
;
IN:
classes.struct
:
malloc-struct
( class -- struct )
[
>c-ptr
malloc-byte-array
]
[
1
swap
heap-size
calloc
]
init-struct
;
inline