docs.unity3d.com
    目次を表示する/隠す

    Struct UnsafeScratchAllocator

    A fixed-size buffer from which you can make allocations.

    Namespace: Unity.Collections.LowLevel.Unsafe
    Syntax
    public struct UnsafeScratchAllocator
    Remarks

    Allocations from a scratch allocator are not individually deallocated. Instead, when you're done using all the allocations from a scratch allocator, you dispose the allocator as a whole.

    Constructors

    UnsafeScratchAllocator(Void*, Int32)

    Initializes and returns an instance of UnsafeScratchAllocator.

    Declaration
    public UnsafeScratchAllocator(void *ptr, int capacityInBytes)
    Parameters
    Type Name Description
    Void* ptr

    An existing buffer to use as the allocator's internal buffer.

    Int32 capacityInBytes

    The size in bytes of the internal buffer.

    Methods

    Allocate(Int32, Int32)

    Returns an allocation from the allocator's internal buffer.

    Declaration
    public void *Allocate(int sizeInBytes, int alignmentInBytes)
    Parameters
    Type Name Description
    Int32 sizeInBytes

    The size of the new allocation.

    Int32 alignmentInBytes

    The alignment of the new allocation.

    Returns
    Type Description
    Void*

    A pointer to the new allocation.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the new allocation would exceed the capacity of the allocator.

    Allocate<T>(Int32)

    Returns an allocation from the allocator's internal buffer.

    Declaration
    public void *Allocate<T>(int count = 1)
        where T : struct
    Parameters
    Type Name Description
    Int32 count

    The number of elements to allocate space for. Defaults to 1.

    Returns
    Type Description
    Void*

    A pointer to the new allocation.

    Type Parameters
    Name Description
    T

    The type of element to allocate space for.

    Remarks

    The allocation size in bytes is at least count * sizeof(T). The space consumed by the allocation may be a little larger than this size due to alignment.

    Exceptions
    Type Condition
    ArgumentException

    Thrown if the new allocation would exceed the capacity of the allocator.

    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)