コード例 #1
0
        public void EnsureMemoryCleaned()
        {
            var x = new DisposableUnmanagedMemory(sizeof(int));

            Marshal.WriteInt32(x.Handler, 42);
            x.Dispose();
            Assert.AreEqual(x.Handler, IntPtr.Zero);
        }
コード例 #2
0
        public void SuccessUsageOfRegularAllocator()
        {
            var x = new DisposableUnmanagedMemory(sizeof(int));

            Marshal.WriteInt32(x.Handler, 42);
            var result = Marshal.ReadInt32(x.Handler);

            x.Dispose();
            Assert.AreEqual(result, 42);
        }