1 ! (c)2009 Joe Groff bsd license
2 USING: accessors alien alien.c-types alien.data destructors kernel libc math ;
10 ERROR: not-enough-pile-space pile ;
13 [ [ free ] when* f ] change-underlying drop ;
15 : <pile> ( size -- pile )
16 [ malloc ] keep 0 pile boa ;
18 : pile-empty ( pile -- )
21 : pile-alloc ( pile size -- alien )
23 [ [ ] [ size>> ] [ offset>> ] tri ] dip +
24 < [ not-enough-pile-space ] [ drop ] if
26 drop [ offset>> ] [ underlying>> ] bi <displaced-alien>
28 [ + ] curry change-offset drop
31 : <pile-c-object> ( pile c-type -- alien )
32 heap-size pile-alloc ; inline
34 : <pile-c-array> ( pile n c-type -- alien )
35 heap-size * pile-alloc ; inline
37 : pile-align ( pile align -- pile )
38 [ align ] curry change-offset ;