|
|
|
@ -2,6 +2,7 @@ |
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Buffers; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using Xunit; |
|
|
|
@ -36,9 +37,26 @@ namespace SixLabors.ImageSharp.Tests.Memory.Allocators |
|
|
|
Assert.Equal("length", ex.ParamName); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Explicit, Size = 512)] |
|
|
|
private struct BigStruct |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|