mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 31 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Buffers; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl.Memory; |
|||
|
|||
internal interface IJxlMemoryManager |
|||
{ |
|||
IMemoryOwner<T> Allocate<T>(int size); |
|||
IMemoryOwner<byte> Allocate(int size); |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
// Copyright (c) Six Labors.
|
|||
// Licensed under the Six Labors Split License.
|
|||
|
|||
using System.Buffers; |
|||
|
|||
namespace SixLabors.ImageSharp.Formats.Jxl.Memory; |
|||
|
|||
/// <summary>
|
|||
/// Allows allocation and deallocation of managed memory.
|
|||
/// </summary>
|
|||
internal sealed class JxlMemoryManager : IJxlMemoryManager |
|||
{ |
|||
public static readonly JxlMemoryManager Instance = new(); |
|||
|
|||
public IMemoryOwner<T> Allocate<T>(int size) => MemoryPool<T>.Shared.Rent(size); |
|||
|
|||
public IMemoryOwner<byte> Allocate(int size) => this.Allocate<byte>(size); |
|||
} |
|||
Loading…
Reference in new issue