Prev | Current Page 1054 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

However, like Arrays, you have to define how many items will be
stored with this pointer, even if it is just one value. This is where alloc_root becomes useful. Not only
does it register the pointer address with the garbage collector, but it also allows the setting of the number
of value structs stored using the pointer, represented by its solitary parameter.
free_root()
free_root is the second half of alloc_root , in that it frees any memory allocated with alloc_root .
This is not done immediately, however, but at the leisure of the garbage collector, which promises to tidy
the memory sometime after the call is made, but no sooner.
It is important to remember that the garbage collector will not free memory allocated with alloc_root
without the explicit call to free_root .
alloc()
alloc is a function very similar in use as the C function malloc . It is used for values that are not static,
thus can and should be used where alloc_root cannot.
Unlike alloc_root , alloc doesn ??™ t need to be explicitly freed.


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