Пример #1
0
        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);
            }
        }
Пример #2
0
 public static IntPtr CoTaskMemReAlloc(IntPtr pv, IntPtr cb)
 {
     return(Marshal.ReAllocCoTaskMem(pv, (int)cb));
 }