Package org.lwjgl.glfw
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
Custom heap memory allocator.
This describes a custom heap memory allocator for GLFW. To set an allocator, pass it to InitAllocator before initializing the library.
Layout
struct GLFWallocator {
GLFWallocatefun allocate();
GLFWreallocatefun reallocate();
GLFWdeallocatefun deallocate();
void * user();
}- Since:
- version 3.4
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.lwjgl.system.Struct
org.lwjgl.system.Struct.StructValidationNested classes/interfaces inherited from interface org.lwjgl.system.Pointer
org.lwjgl.system.Pointer.Default -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe struct alignment in bytes.static final intThe struct member offsets.static final intThe struct member offsets.static final intThe struct member offsets.static final intThe struct size in bytes.static final intThe struct member offsets.Fields inherited from interface org.lwjgl.system.Pointer
BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionGLFWAllocator(ByteBuffer container) Creates aGLFWAllocatorinstance at the current position of the specifiedByteBuffercontainer. -
Method Summary
Modifier and TypeMethodDescriptionallocate()the memory allocation functionallocate(GLFWAllocateCallbackI value) Sets the specified value to theallocate()field.static GLFWAllocatorcalloc()Returns a newGLFWAllocatorinstance allocated withmemCalloc.static GLFWAllocator.Buffercalloc(int capacity) Returns a newGLFWAllocator.Bufferinstance allocated withmemCalloc.static GLFWAllocator.Buffercalloc(int capacity, org.lwjgl.system.MemoryStack stack) Returns a newGLFWAllocator.Bufferinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.static GLFWAllocatorcalloc(org.lwjgl.system.MemoryStack stack) Returns a newGLFWAllocatorinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.static GLFWAllocatorcreate()Returns a newGLFWAllocatorinstance allocated withBufferUtils.static GLFWAllocator.Buffercreate(int capacity) Returns a newGLFWAllocator.Bufferinstance allocated withBufferUtils.static GLFWAllocatorcreate(long address) Returns a newGLFWAllocatorinstance for the specified memory address.static GLFWAllocator.Buffercreate(long address, int capacity) Create aGLFWAllocator.Bufferinstance at the specified memory.static @Nullable GLFWAllocatorcreateSafe(long address) static @Nullable GLFWAllocator.BuffercreateSafe(long address, int capacity) the memory deallocation functionSets the specified value to thedeallocate()field.static GLFWAllocatormalloc()Returns a newGLFWAllocatorinstance allocated withmemAlloc.static GLFWAllocator.Buffermalloc(int capacity) Returns a newGLFWAllocator.Bufferinstance allocated withmemAlloc.static GLFWAllocator.Buffermalloc(int capacity, org.lwjgl.system.MemoryStack stack) Returns a newGLFWAllocator.Bufferinstance allocated on the specifiedMemoryStack.static GLFWAllocatormalloc(org.lwjgl.system.MemoryStack stack) Returns a newGLFWAllocatorinstance allocated on the specifiedMemoryStack.static GLFWAllocateCallbacknallocate(long struct) Unsafe version ofallocate().static voidnallocate(long struct, GLFWAllocateCallbackI value) Unsafe version ofallocate.static GLFWDeallocateCallbackndeallocate(long struct) Unsafe version ofdeallocate().static voidndeallocate(long struct, GLFWDeallocateCallbackI value) Unsafe version ofdeallocate.static GLFWReallocateCallbacknreallocate(long struct) Unsafe version ofreallocate().static voidnreallocate(long struct, GLFWReallocateCallbackI value) Unsafe version ofreallocate.static longnuser(long struct) Unsafe version ofuser().static voidnuser(long struct, long value) Unsafe version ofuser.the memory reallocation functionSets the specified value to thereallocate()field.set(GLFWAllocateCallbackI allocate, GLFWReallocateCallbackI reallocate, GLFWDeallocateCallbackI deallocate, long user) Initializes this struct with the specified values.set(GLFWAllocator src) Copies the specified struct data to this struct.intsizeof()longuser()the user pointer for this custom allocator.user(long value) Sets the specified value to theuser()field.static voidvalidate(long struct) Validates pointer members that should not beNULL.Methods inherited from class org.lwjgl.system.Struct
clear, free, isNull, validate, validateMethods inherited from class org.lwjgl.system.Pointer.Default
address, equals, hashCode, toStringMethods inherited from interface org.lwjgl.system.NativeResource
close, free
-
Field Details
-
SIZEOF
public static final int SIZEOFThe struct size in bytes. -
ALIGNOF
public static final int ALIGNOFThe struct alignment in bytes. -
ALLOCATE
public static final int ALLOCATEThe struct member offsets. -
REALLOCATE
public static final int REALLOCATEThe struct member offsets. -
DEALLOCATE
public static final int DEALLOCATEThe struct member offsets. -
USER
public static final int USERThe struct member offsets.
-
-
Constructor Details
-
GLFWAllocator
Creates aGLFWAllocatorinstance at the current position of the specifiedByteBuffercontainer. 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:
sizeofin classorg.lwjgl.system.Struct<GLFWAllocator>
-
allocate
the memory allocation function -
reallocate
the memory reallocation function -
deallocate
the memory deallocation function -
user
public long user()the user pointer for this custom allocator. This value will be passed to the allocator functions. -
allocate
Sets the specified value to theallocate()field. -
reallocate
Sets the specified value to thereallocate()field. -
deallocate
Sets the specified value to thedeallocate()field. -
user
Sets the specified value to theuser()field. -
set
public GLFWAllocator set(GLFWAllocateCallbackI allocate, GLFWReallocateCallbackI reallocate, GLFWDeallocateCallbackI deallocate, long user) Initializes this struct with the specified values. -
set
Copies the specified struct data to this struct.- Parameters:
src- the source struct- Returns:
- this struct
-
malloc
Returns a newGLFWAllocatorinstance allocated withmemAlloc. The instance must be explicitly freed. -
calloc
Returns a newGLFWAllocatorinstance allocated withmemCalloc. The instance must be explicitly freed. -
create
Returns a newGLFWAllocatorinstance allocated withBufferUtils. -
create
Returns a newGLFWAllocatorinstance for the specified memory address. -
createSafe
-
malloc
Returns a newGLFWAllocator.Bufferinstance allocated withmemAlloc. The instance must be explicitly freed.- Parameters:
capacity- the buffer capacity
-
calloc
Returns a newGLFWAllocator.Bufferinstance allocated withmemCalloc. The instance must be explicitly freed.- Parameters:
capacity- the buffer capacity
-
create
Returns a newGLFWAllocator.Bufferinstance allocated withBufferUtils.- Parameters:
capacity- the buffer capacity
-
create
Create aGLFWAllocator.Bufferinstance at the specified memory.- Parameters:
address- the memory addresscapacity- the buffer capacity
-
createSafe
-
malloc
Returns a newGLFWAllocatorinstance allocated on the specifiedMemoryStack.- Parameters:
stack- the stack from which to allocate
-
calloc
Returns a newGLFWAllocatorinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.- Parameters:
stack- the stack from which to allocate
-
malloc
Returns a newGLFWAllocator.Bufferinstance allocated on the specifiedMemoryStack.- Parameters:
capacity- the buffer capacitystack- the stack from which to allocate
-
calloc
Returns a newGLFWAllocator.Bufferinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.- Parameters:
capacity- the buffer capacitystack- the stack from which to allocate
-
nallocate
Unsafe version ofallocate(). -
nreallocate
Unsafe version ofreallocate(). -
ndeallocate
Unsafe version ofdeallocate(). -
nuser
public static long nuser(long struct) Unsafe version ofuser(). -
nallocate
Unsafe version ofallocate. -
nreallocate
Unsafe version ofreallocate. -
ndeallocate
Unsafe version ofdeallocate. -
nuser
public static void nuser(long struct, long value) Unsafe version ofuser. -
validate
public static void validate(long struct) Validates pointer members that should not beNULL.- Parameters:
struct- the struct to validate
-