internal unsafe static void *CoTaskMemAllocAndZeroMemory(global::System.IntPtr size) { void *ptr; ptr = PInvokeMarshal.CoTaskMemAlloc((UIntPtr)(void *)size).ToPointer(); // PInvokeMarshal.CoTaskMemAlloc will throw OOMException if out of memory Debug.Assert(ptr != null); Buffer.ZeroMemory((byte *)ptr, size.ToInt64()); return(ptr); }