package cpp; @:include("stdlib.h") extern class Stdlib { @:native("malloc") public static function nativeMalloc(bytes:Int) : cpp.RawPointer return null; @:native("calloc") public static function nativeCalloc(bytes:Int) : cpp.RawPointer return null; @:native("realloc") public static function nativeRealloc(inPtr:cpp.RawPointer,bytes:Int) : cpp.RawPointer return null; @:native("free") public static function nativeFree(ptr:cpp.RawPointer) : Void { } @:native("hx::ClassSizeOf") @:templatedCall public static function sizeof(t:T) : Int { } inline public static function malloc(bytes:Int) : cpp.Pointer return cast nativeMalloc(bytes); inline public static function calloc(bytes:Int) : cpp.Pointer return cast nativeCalloc(bytes); inline public static function realloc(ioPtr:cpp.Pointer, bytes:Int) : Void ioPtr.setRaw( nativeRealloc(cast ioPtr.ptr, bytes) ); inline public static function free(ptr:cpp.Pointer) : Void { if (ptr!=null) { nativeFree(cast ptr.ptr); ptr.ptr = null; } } }