Esempio n. 1
0
        public void MemoryAllocator_Setter_Roundtrips()
        {
            MemoryAllocator customAllocator = new SimpleGcMemoryAllocator();
            var             config          = new Configuration()
            {
                MemoryAllocator = customAllocator
            };

            Assert.Same(customAllocator, config.MemoryAllocator);
        }
        public unsafe void Allocate_MemoryIsPinnableMultipleTimes()
        {
            SimpleGcMemoryAllocator allocator = this.MemoryAllocator;

            using IMemoryOwner <byte> memoryOwner = allocator.Allocate <byte>(100);

            using (MemoryHandle pin = memoryOwner.Memory.Pin())
            {
                Assert.NotEqual(IntPtr.Zero, (IntPtr)pin.Pointer);
            }

            using (MemoryHandle pin = memoryOwner.Memory.Pin())
            {
                Assert.NotEqual(IntPtr.Zero, (IntPtr)pin.Pointer);
            }
        }