Prev | Current Page 1055 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

This is because any memory assigned by
alloc will be freed by the garbage collector sometime after the last pointer to reference the allocated
memory is no longer reachable.
Like malloc , alloc accepts a single parameter stating the number of bytes you want stored in the newly
garbage collector ??“ managed memory. If you don ??™ t know the size of bytes required to, say, store an object
in the allocated memory, then use the C function sizeof to acquire it:
SomeStruct* data = alloc( sizeof( OtherObject ) );
Garbage Collecting Abstract Values
If you ??™ re dealing with Neko values, then you don ??™ t need to worry about garbage collection, as Neko
already handles this. However, any abstract values you use in your libraries are kind of an unknown
entity, so Neko chooses not to handle them. Luckily, though, Neko does provide a way to callback a set
function when garbage collection should occur on an abstract value, so that you can handle this yourself.
Chapter 20: Extending ha X e with C/C++
573
To flag an abstract value for a garbage collection callback, you need to use the function val_gc .


Pages:
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067