Cpp pointer to Bytes?

I guess this is more of a general Haxe question but…
I have a Pointer pointing at an array from cpp… Now how do i get this data into haxe Bytes?

This works but is way to slow:

var uip:Pointer<UInt8> = myData();
for (i in 0...bytes.length) 
{
    bytes.set(i, uip.at(i));
}

Any advice on how else to do it?

I don’t use cpp.Pointer much, but browsing around, this might work?

var bytes = Bytes.ofData (uip.toUnmanagedArray (length));

Yes i looked at that too… but in haxe 3.21 :

cpp.Pointer<cpp.UInt8> has no field toUnmanagedArray 

Now Haxe 3.3 can do this…
but getting openfl / hxcpp to compile on haxe 3.3 doesnt seem to work…

[Edit]
Ok, found a solution for Haxe 3.21 :slight_smile:

var arr:Array<UInt8> = [];
NativeArray.setUnmanagedData(arr, stream.getData(), length);
bytes = Bytes.ofData(cast(arr));