Class ExrAllocator

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class ExrAllocator extends Struct<ExrAllocator> implements NativeResource
struct ExrAllocator {
    void * userdata;
    void * (* alloc) (void * userdata, size_t size, size_t alignment);
    void * (* realloc) (void * userdata, void * ptr, size_t old_size, size_t new_size, size_t alignment);
    void (* free) (void * userdata, void * ptr, size_t 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.
    • USERDATA

      public static final int USERDATA
      The struct member offsets.
    • ALLOC

      public static final int ALLOC
      The struct member offsets.
    • REALLOC

      public static final int REALLOC
      The struct member offsets.
    • FREE

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

    • ExrAllocator

      public ExrAllocator(ByteBuffer container)
      Creates a ExrAllocator 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<ExrAllocator>
    • userdata

      @NativeType("void *") public long userdata()
      Returns:
      the value of the userdata field.
    • alloc

      @NativeType("void * (*) (void *, size_t, size_t)") public ExrAlloc alloc()
      Returns:
      the value of the alloc field.
    • realloc

      @NativeType("void * (*) (void *, void *, size_t, size_t, size_t)") public ExrRealloc realloc()
      Returns:
      the value of the realloc field.
    • free$

      @NativeType("void (*) (void *, void *, size_t)") public ExrFree free$()
      Returns:
      the value of the free field.
    • userdata

      public ExrAllocator userdata(@NativeType("void *") long value)
      Sets the specified value to the userdata field.
    • alloc

      public ExrAllocator alloc(@NativeType("void * (*) (void *, size_t, size_t)") ExrAllocI value)
      Sets the specified value to the alloc field.
    • realloc

      public ExrAllocator realloc(@NativeType("void * (*) (void *, void *, size_t, size_t, size_t)") ExrReallocI value)
      Sets the specified value to the realloc field.
    • free$

      public ExrAllocator free$(@NativeType("void (*) (void *, void *, size_t)") ExrFreeI value)
      Sets the specified value to the free field.
    • set

      public ExrAllocator set(long userdata, ExrAllocI alloc, ExrReallocI realloc, ExrFreeI free$)
      Initializes this struct with the specified values.
    • set

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static ExrAllocator.Buffer calloc(int capacity, MemoryStack stack)
      Returns a new ExrAllocator.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
    • nuserdata

      public static long nuserdata(long struct)
      Unsafe version of userdata().
    • nalloc

      public static ExrAlloc nalloc(long struct)
      Unsafe version of alloc().
    • nrealloc

      public static ExrRealloc nrealloc(long struct)
      Unsafe version of realloc().
    • nfree$

      public static ExrFree nfree$(long struct)
      Unsafe version of free$().
    • nuserdata

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

      public static void nalloc(long struct, ExrAllocI value)
      Unsafe version of alloc.
    • nrealloc

      public static void nrealloc(long struct, ExrReallocI value)
      Unsafe version of realloc.
    • nfree$

      public static void nfree$(long struct, ExrFreeI value)
      Unsafe version of free$.
    • validate

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