Class GLFWAllocator

java.lang.Object
org.lwjgl.system.Pointer.Default
org.lwjgl.system.Struct<GLFWAllocator>
org.lwjgl.glfw.GLFWAllocator
All Implemented Interfaces:
AutoCloseable, org.lwjgl.system.NativeResource, org.lwjgl.system.Pointer

public class GLFWAllocator extends org.lwjgl.system.Struct<GLFWAllocator> implements org.lwjgl.system.NativeResource
A custom memory allocator that can be set with InitAllocator.

Layout


 struct GLFWallocator {
     GLFWallocatefun allocate();
     GLFWreallocatefun reallocate();
     GLFWdeallocatefun deallocate();
     void * user();
 }
Since:
version 3.4
  • Field Details

    • SIZEOF

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

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

      public static final int ALLOCATE
      The struct member offsets.
    • REALLOCATE

      public static final int REALLOCATE
      The struct member offsets.
    • DEALLOCATE

      public static final int DEALLOCATE
      The struct member offsets.
    • USER

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

    • GLFWAllocator

      public GLFWAllocator(ByteBuffer container)
      Creates a GLFWAllocator 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()
      Specified by:
      sizeof in class org.lwjgl.system.Struct<GLFWAllocator>
    • allocate

      public GLFWAllocateCallback allocate()
      the memory allocation callback
    • reallocate

      public GLFWReallocateCallback reallocate()
      the memory reallocation callback
    • deallocate

      public GLFWDeallocateCallback deallocate()
      the memory deallocation callback
    • user

      public long user()
      a user-defined pointer that will be passed to the callbacks
    • allocate

      public GLFWAllocator allocate(GLFWAllocateCallbackI value)
      Sets the specified value to the allocate() field.
    • reallocate

      public GLFWAllocator reallocate(GLFWReallocateCallbackI value)
      Sets the specified value to the reallocate() field.
    • deallocate

      public GLFWAllocator deallocate(GLFWDeallocateCallbackI value)
      Sets the specified value to the deallocate() field.
    • user

      public GLFWAllocator user(long value)
      Sets the specified value to the user() field.
    • set

      public GLFWAllocator set(GLFWAllocateCallbackI allocate, GLFWReallocateCallbackI reallocate, GLFWDeallocateCallbackI deallocate, long user)
      Initializes this struct with the specified values.
    • set

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static GLFWAllocator.Buffer calloc(int capacity, org.lwjgl.system.MemoryStack stack)
      Returns a new GLFWAllocator.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
    • nallocate

      public static GLFWAllocateCallback nallocate(long struct)
      Unsafe version of allocate().
    • nreallocate

      public static GLFWReallocateCallback nreallocate(long struct)
      Unsafe version of reallocate().
    • ndeallocate

      public static GLFWDeallocateCallback ndeallocate(long struct)
      Unsafe version of deallocate().
    • nuser

      public static long nuser(long struct)
      Unsafe version of user().
    • nallocate

      public static void nallocate(long struct, GLFWAllocateCallbackI value)
      Unsafe version of allocate.
    • nreallocate

      public static void nreallocate(long struct, GLFWReallocateCallbackI value)
      Unsafe version of reallocate.
    • ndeallocate

      public static void ndeallocate(long struct, GLFWDeallocateCallbackI value)
      Unsafe version of deallocate.
    • nuser

      public static void nuser(long struct, long value)
      Unsafe version of user.
    • validate

      public static void validate(long struct)
      Validates pointer members that should not be NULL.
      Parameters:
      struct - the struct to validate