ByteBufferAllocator

public struct ByteBufferAllocator

The preferred allocator for ByteBuffer values. The allocation strategy is opaque but is currently libc’s malloc, realloc and free.

Note

ByteBufferAllocator is thread-safe.
  • Create a fresh ByteBufferAllocator. In the future the allocator might use for example allocation pools and therefore it’s recommended to reuse ByteBufferAllocators where possible instead of creating fresh ones in many places.

    Declaration

    Swift

    public init()
  • Request a freshly allocated ByteBuffer of size capacity or larger.

    Declaration

    Swift

    public func buffer(capacity: Int) -> ByteBuffer

    Parameters

    capacity

    The capacity of the returned ByteBuffer.