Class NkAllocator

    • 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()
        Description copied from class: Struct
        Returns sizeof(struct).
        Specified by:
        sizeof in class 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​(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.
      • 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​(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​(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
      • 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
      • callocStack

        public static NkAllocator.Buffer callocStack​(int capacity,
                                                     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.