Am 15.08.2011 19:16, schrieb mimocrocodil:
I obtain immutable(byte)* and int where contained length of bytes block from C
library.
Can I convert this into byte[] without explict copying etc.
Something like:
byte* p; // bytes
int size; // size of bytes block
byte[] b;
b.length = size;
b.ptr = p;
// now b contains bytes from library
Pointers support indexing (like C) but additionally also slicing so if
you have a byte* b and a int/long/size_t (or similiar) len then
b[0.. len]
is a slice starting b conatining len elements of type typeof(*b)[].