Skip to content

Instantly share code, notes, and snippets.

@bnayae
Created May 12, 2018 19:33
Show Gist options
  • Save bnayae/24f81f845fc7468833e2f24da3f35479 to your computer and use it in GitHub Desktop.
Save bnayae/24f81f845fc7468833e2f24da3f35479 to your computer and use it in GitHub Desktop.
IntPtr pdata = Marshal.AllocHGlobal(Data.Length * sizeof(int));
int* data = (int*)pdata;
try
{
Marshal.Copy(Data, 0, pdata, Data.Length);
for (int i = 0; i < Data.Length - (BUFFER_SIZE + 1); i += BUFFER_SIZE)
{
int* sub = data + i;
if (sub[BUFFER_SIZE - 1] != i + BUFFER_SIZE - 1)
throw new Exception();
}
}
finally
{
Marshal.FreeHGlobal(pdata);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment