Hi all, especially Nicolas, i've updated the "cptr" library i use as a utility library for the -gl etc bindings to -hopefully- be memory-safe. Now, the size of allocated memory (specifically, the number of elements of the specific type) are stored in a structure alongside the pointer itself. Access is checked with that and results in exceptions if out of range. The allocated pointers will be garbage-collected.
cptr allows you to allocate, read/write and convert to/from neko arrays, as well as wrap existing pointers from C. it simplifys bindings (like OpenGL), where plain pointers are often used, and allows different neko-C libraries to share larger blocks of data in an efficient manner. i have also added a few tests using haxe's brand-new unittest framework, including one for memory leaks which will only work on linux (as it uses /proc to find the memory usage of the current process). the tests will be enabled if you compile with "-D test" and use CPtr as main class. furthermore, the little library includes some eclectic utility functions that will at some point move out to a different utility library. there is still open issues with NULL pointers, as handling these might sometimes be a valid thing to do, and casting between pointer types. i have ideas how to handle these situations, but currently i have no real use for them, so they're just delayed. i'd be happy if i can get some eyeballs on this; handling pointers in an efficient and memory-safe manner is a pretty fundamental thing for my further work on neko bindings. http://iterative.org/neko/bindings/neko-cptr-0.0.2.tbz2 -dan ps: Nicolas, sorry for repeatedly getting your name wrong. It just occurred to me that actually you use the exact same spelling as my own brother, so it shouldnt happen again ;) -- http://0xDF.com/ http://iterative.org/ -- Neko : One VM to run them all (http://nekovm.org)
