Class NkBuffer

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class NkBuffer extends Struct<NkBuffer> implements NativeResource

 struct nk_buffer {
     {@link NkBufferMarker struct nk_buffer_marker} marker[2];
     {@link NkAllocator struct nk_allocator} pool;
     enum nk_allocation_type type;
     {@link NkMemory struct nk_memory} memory;
     float grow_factor;
     nk_size allocated;
     nk_size needed;
     nk_size calls;
     nk_size size;
 }
  • Field Details

    • SIZEOF

      public static final int SIZEOF
      The struct size in bytes.
    • ALIGNOF

      public static final int ALIGNOF
      The struct alignment in bytes.
    • MARKER

      public static final int MARKER
      The struct member offsets.
    • POOL

      public static final int POOL
      The struct member offsets.
    • TYPE

      public static final int TYPE
      The struct member offsets.
    • MEMORY

      public static final int MEMORY
      The struct member offsets.
    • GROW_FACTOR

      public static final int GROW_FACTOR
      The struct member offsets.
    • ALLOCATED

      public static final int ALLOCATED
      The struct member offsets.
    • NEEDED

      public static final int NEEDED
      The struct member offsets.
    • CALLS

      public static final int CALLS
      The struct member offsets.
    • SIZE

      public static final int SIZE
      The struct member offsets.
  • Constructor Details

    • NkBuffer

      public NkBuffer(ByteBuffer container)
      Creates a NkBuffer instance at the current position of the specified ByteBuffer container. Changes to the buffer's content will be visible to the struct instance and vice versa.

      The created instance holds a strong reference to the container object.

  • Method Details

    • sizeof

      public int sizeof()
      Description copied from class: Struct
      Returns sizeof(struct).
      Specified by:
      sizeof in class Struct<NkBuffer>
    • marker

      public NkBufferMarker.Buffer marker()
      Returns:
      a NkBufferMarker.Buffer view of the marker field.
    • marker

      public NkBufferMarker marker(int index)
      Returns:
      a NkBufferMarker view of the struct at the specified index of the marker field.
    • pool

      public NkAllocator pool()
      Returns:
      a NkAllocator view of the pool field.
    • type

      public int type()
      Returns:
      the value of the type field.
    • memory

      public NkMemory memory()
      Returns:
      a NkMemory view of the memory field.
    • grow_factor

      public float grow_factor()
      Returns:
      the value of the grow_factor field.
    • allocated

      public long allocated()
      Returns:
      the value of the allocated field.
    • needed

      public long needed()
      Returns:
      the value of the needed field.
    • calls

      public long calls()
      Returns:
      the value of the calls field.
    • size

      public long size()
      Returns:
      the value of the size field.
    • malloc

      public static NkBuffer malloc()
      Returns a new NkBuffer instance allocated with memAlloc. The instance must be explicitly freed.
    • calloc

      public static NkBuffer calloc()
      Returns a new NkBuffer instance allocated with memCalloc. The instance must be explicitly freed.
    • create

      public static NkBuffer create()
      Returns a new NkBuffer instance allocated with BufferUtils.
    • create

      public static NkBuffer create(long address)
      Returns a new NkBuffer instance for the specified memory address.
    • createSafe

      public static @Nullable NkBuffer createSafe(long address)
      Like create, but returns null if address is NULL.
    • malloc

      public static NkBuffer.Buffer malloc(int capacity)
      Returns a new NkBuffer.Buffer instance allocated with memAlloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • calloc

      public static NkBuffer.Buffer calloc(int capacity)
      Returns a new NkBuffer.Buffer instance allocated with memCalloc. The instance must be explicitly freed.
      Parameters:
      capacity - the buffer capacity
    • create

      public static NkBuffer.Buffer create(int capacity)
      Returns a new NkBuffer.Buffer instance allocated with BufferUtils.
      Parameters:
      capacity - the buffer capacity
    • create

      public static NkBuffer.Buffer create(long address, int capacity)
      Create a NkBuffer.Buffer instance at the specified memory.
      Parameters:
      address - the memory address
      capacity - the buffer capacity
    • createSafe

      public static @Nullable NkBuffer.Buffer createSafe(long address, int capacity)
      Like create, but returns null if address is NULL.
    • mallocStack

      @Deprecated public static NkBuffer mallocStack()
      Deprecated.
      Deprecated for removal in 3.4.0. Use malloc(MemoryStack) instead.
    • callocStack

      @Deprecated public static NkBuffer callocStack()
      Deprecated.
      Deprecated for removal in 3.4.0. Use calloc(MemoryStack) instead.
    • mallocStack

      @Deprecated public static NkBuffer mallocStack(MemoryStack stack)
      Deprecated.
      Deprecated for removal in 3.4.0. Use malloc(MemoryStack) instead.
    • callocStack

      @Deprecated public static NkBuffer callocStack(MemoryStack stack)
      Deprecated.
      Deprecated for removal in 3.4.0. Use calloc(MemoryStack) instead.
    • mallocStack

      @Deprecated public static NkBuffer.Buffer mallocStack(int capacity)
      Deprecated.
      Deprecated for removal in 3.4.0. Use malloc(int, MemoryStack) instead.
    • callocStack

      @Deprecated public static NkBuffer.Buffer callocStack(int capacity)
      Deprecated.
      Deprecated for removal in 3.4.0. Use calloc(int, MemoryStack) instead.
    • mallocStack

      @Deprecated public static NkBuffer.Buffer mallocStack(int capacity, MemoryStack stack)
      Deprecated.
      Deprecated for removal in 3.4.0. Use malloc(int, MemoryStack) instead.
    • callocStack

      @Deprecated public static NkBuffer.Buffer callocStack(int capacity, MemoryStack stack)
      Deprecated.
      Deprecated for removal in 3.4.0. Use calloc(int, MemoryStack) instead.
    • malloc

      public static NkBuffer malloc(MemoryStack stack)
      Returns a new NkBuffer instance allocated on the specified MemoryStack.
      Parameters:
      stack - the stack from which to allocate
    • calloc

      public static NkBuffer calloc(MemoryStack stack)
      Returns a new NkBuffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      stack - the stack from which to allocate
    • malloc

      public static NkBuffer.Buffer malloc(int capacity, MemoryStack stack)
      Returns a new NkBuffer.Buffer instance allocated on the specified MemoryStack.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • calloc

      public static NkBuffer.Buffer calloc(int capacity, MemoryStack stack)
      Returns a new NkBuffer.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
      Parameters:
      capacity - the buffer capacity
      stack - the stack from which to allocate
    • nmarker

      public static NkBufferMarker.Buffer nmarker(long struct)
      Unsafe version of marker().
    • nmarker

      public static NkBufferMarker nmarker(long struct, int index)
      Unsafe version of marker.
    • npool

      public static NkAllocator npool(long struct)
      Unsafe version of pool().
    • ntype

      public static int ntype(long struct)
      Unsafe version of type().
    • nmemory

      public static NkMemory nmemory(long struct)
      Unsafe version of memory().
    • ngrow_factor

      public static float ngrow_factor(long struct)
      Unsafe version of grow_factor().
    • nallocated

      public static long nallocated(long struct)
      Unsafe version of allocated().
    • nneeded

      public static long nneeded(long struct)
      Unsafe version of needed().
    • ncalls

      public static long ncalls(long struct)
      Unsafe version of calls().
    • nsize

      public static long nsize(long struct)
      Unsafe version of size().