When working with stackalloc
memory I would like to copy its content to/from an array. I am looking for something similar to Buffer.BlockCopy
which would allow me to pass offset in source data and offset in destination.
Is there is such method for stackalloc
memory? Or in general -- how to copy memory in one go, without iterating element by element?
int i = 0;
double* window = stackalloc double[max_window_size];
for (int x = 0; x < width; ++x)
{
window[i] = array[x, y];
++i;
}
Important catch: the array I am asking about already exists. So I cannot create an array from stackalloc
memory and then copy this array to existing array, because it would invalidate whole point of using stackalloc
in the first place.