public static void ReAllocCoTaskMem_DataCopied() { const int Size = 3; IntPtr p1 = Marshal.AllocCoTaskMem(Size); IntPtr p2 = p1; try { WriteBytes(p1, Size); int add = 1; do { p2 = Marshal.ReAllocCoTaskMem(p2, Size + add); VerifyBytes(p2, Size); add++; }while (p2 == p1); // stop once we've validated moved case } finally { Marshal.FreeCoTaskMem(p2); } }
public static IntPtr CoTaskMemReAlloc(IntPtr pv, IntPtr cb) { return(Marshal.ReAllocCoTaskMem(pv, (int)cb)); }