[Vm-dev] Primitive to crop a ByteArray?

Mariano Martinez Peck marianopeck at gmail.com
Thu Nov 8 15:22:35 UTC 2012


Hi guys. I have the following scenario. I have a buffer (ByteArray)
that I pass by FFI to a function of size N. This function puts data in
the array and answers me the M number of bytes that it put. M <= N.
Finally, I need to copy the array of size N to the accuare size M.
To do that, I am using #copyFrom:to:. If the ByteArray is large (which
could be the case), this function takes significant time because it
needs to allocate space for the new large resulting array. So...is
there a destructive primitive where I can "crop" the existing array,
modify its size field and mark the remaining bytes as "free space for
the heap".

Do we have a primitive for that?

Thanks,

--
Mariano
http://marianopeck.wordpress.com


More information about the Vm-dev mailing list