Class NkAllocator

  • All Implemented Interfaces:
    java.lang.AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

    public class NkAllocator
    extends org.lwjgl.system.Struct
    implements org.lwjgl.system.NativeResource

    Layout

    
     struct nk_allocator {
         nk_handle userdata;
         nk_plugin_alloc alloc;
         nk_plugin_free mfree;
     }
    • Field Detail

      • SIZEOF

        The struct size in bytes.
      • ALIGNOF

        The struct alignment in bytes.
      • USERDATA, ALLOC, MFREE

        The struct member offsets.
    • Constructor Detail

      • NkAllocator

        public NkAllocator​(java.nio.ByteBuffer container)
        Creates a NkAllocator 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 Detail

      • sizeof

        public int sizeof()
        Specified by:
        sizeof in class org.lwjgl.system.Struct
      • userdata

        public NkHandle userdata()
        Returns a NkHandle view of the userdata field.
      • alloc

        @Nullable
        public NkPluginAlloc alloc()
        Returns the value of the alloc field.
      • mfree

        @Nullable
        public NkPluginFree mfree()
        Returns the value of the mfree field.
      • userdata

        public NkAllocator userdata​(java.util.function.Consumer<NkHandle> consumer)
        Passes the userdata field to the specified Consumer.
      • set

        public NkAllocator set​(NkAllocator src)
        Copies the specified struct data to this struct.
        Parameters:
        src - the source struct
        Returns:
        this struct
      • malloc

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

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

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

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

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

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

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

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

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

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

        public static NkAllocator mallocStack()
        Returns a new NkAllocator instance allocated on the thread-local MemoryStack.
      • callocStack

        public static NkAllocator callocStack()
        Returns a new NkAllocator instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
      • mallocStack

        public static NkAllocator mallocStack​(org.lwjgl.system.MemoryStack stack)
        Returns a new NkAllocator instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
      • callocStack

        public static NkAllocator callocStack​(org.lwjgl.system.MemoryStack stack)
        Returns a new NkAllocator instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
      • mallocStack

        public static NkAllocator.Buffer mallocStack​(int capacity)
        Returns a new NkAllocator.Buffer instance allocated on the thread-local MemoryStack.
        Parameters:
        capacity - the buffer capacity
      • callocStack

        public static NkAllocator.Buffer callocStack​(int capacity)
        Returns a new NkAllocator.Buffer instance allocated on the thread-local MemoryStack and initializes all its bits to zero.
        Parameters:
        capacity - the buffer capacity
      • mallocStack

        public static NkAllocator.Buffer mallocStack​(int capacity,
                                                     org.lwjgl.system.MemoryStack stack)
        Returns a new NkAllocator.Buffer instance allocated on the specified MemoryStack.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • callocStack

        public static NkAllocator.Buffer callocStack​(int capacity,
                                                     org.lwjgl.system.MemoryStack stack)
        Returns a new NkAllocator.Buffer instance allocated on the specified MemoryStack and initializes all its bits to zero.
        Parameters:
        stack - the stack from which to allocate
        capacity - the buffer capacity
      • nuserdata

        public static NkHandle nuserdata​(long struct)
        Unsafe version of userdata().
      • nmfree

        @Nullable
        public static NkPluginFree nmfree​(long struct)
        Unsafe version of mfree().
      • nuserdata

        public static void nuserdata​(long struct,
                                     NkHandle value)
        Unsafe version of userdata.
      • nalloc

        public static void nalloc​(long struct,
                                  @Nullable
                                  NkPluginAllocI value)
        Unsafe version of alloc.
      • nmfree

        public static void nmfree​(long struct,
                                  @Nullable
                                  NkPluginFreeI value)
        Unsafe version of mfree.