How safe is this piece of code?
//allocate 10 bytes
IntPtr p = Marshal.AllocHGlobal(10);
byte a = new byte;
for (byte i = 0; i < a.Length; ++i) a[i] = i;
//copy the buffer
Marshal.Copy(a, 0, p, a.Length);
Here's some pictures that shows the memory before and ...
after the copying...