How to convert a MemoryBlock cleanly to a Ptr?

I think it should work like this, for an array of code strings s():

Var Count As Integer = s.Count
Var PtrMB As New MemoryBlock (Count * 8 + 1) // MB for the ptrs
Var LengthMB As New MemoryBlock (Count * 4 + 1) // considering GLInt is an Int32. Didn’t check.
// And considering both arrays follow usual C-Array structure with a trailing 0 Byte.
Count = Count - 1
For q As Integer = 0 to Count
   Var StringMB As MemoryBlock = s(q)
   Var p As Ptr = StringMB
   PtrMB.Ptr(q*8) = p
   LengthMB.Int32Value(q*4) = StringMB.Size
Next q

And then pass PtrMB and LengthMB to the method where both parameters are declared as Ptr.

1 Like