Class spng_alloc

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class spng_alloc extends Struct<spng_alloc> implements NativeResource

 struct spng_alloc {
     {@link spng_malloc_fnI spng_malloc_fn} * malloc_fn;
     {@link spng_realloc_fnI spng_realloc_fn} * realloc_fn;
     {@link spng_calloc_fnI spng_calloc_fn} * calloc_fn;
     {@link spng_free_fnI spng_free_fn} * free_fn;
 }
  • Field Details

    • SIZEOF

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

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

      public static final int MALLOC_FN
      The struct member offsets.
    • REALLOC_FN

      public static final int REALLOC_FN
      The struct member offsets.
    • CALLOC_FN

      public static final int CALLOC_FN
      The struct member offsets.
    • FREE_FN

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

    • spng_alloc

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

      public PointerBuffer malloc_fn(int capacity)
      Returns:
      a PointerBuffer view of the data pointed to by the malloc_fn field.
    • realloc_fn

      public PointerBuffer realloc_fn(int capacity)
      Returns:
      a PointerBuffer view of the data pointed to by the realloc_fn field.
    • calloc_fn

      public PointerBuffer calloc_fn(int capacity)
      Returns:
      a PointerBuffer view of the data pointed to by the calloc_fn field.
    • free_fn

      public PointerBuffer free_fn(int capacity)
      Returns:
      a PointerBuffer view of the data pointed to by the free_fn field.
    • malloc_fn

      public spng_alloc malloc_fn(PointerBuffer value)
      Sets the address of the specified PointerBuffer to the malloc_fn field.
    • realloc_fn

      public spng_alloc realloc_fn(PointerBuffer value)
      Sets the address of the specified PointerBuffer to the realloc_fn field.
    • calloc_fn

      public spng_alloc calloc_fn(PointerBuffer value)
      Sets the address of the specified PointerBuffer to the calloc_fn field.
    • free_fn

      public spng_alloc free_fn(PointerBuffer value)
      Sets the address of the specified PointerBuffer to the free_fn field.
    • set

      public spng_alloc set(PointerBuffer malloc_fn, PointerBuffer realloc_fn, PointerBuffer calloc_fn, PointerBuffer free_fn)
      Initializes this struct with the specified values.
    • set

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static PointerBuffer nmalloc_fn(long struct, int capacity)
      Unsafe version of malloc_fn.
    • nrealloc_fn

      public static PointerBuffer nrealloc_fn(long struct, int capacity)
      Unsafe version of realloc_fn.
    • ncalloc_fn

      public static PointerBuffer ncalloc_fn(long struct, int capacity)
      Unsafe version of calloc_fn.
    • nfree_fn

      public static PointerBuffer nfree_fn(long struct, int capacity)
      Unsafe version of free_fn.
    • nmalloc_fn

      public static void nmalloc_fn(long struct, PointerBuffer value)
      Unsafe version of malloc_fn.
    • nrealloc_fn

      public static void nrealloc_fn(long struct, PointerBuffer value)
      Unsafe version of realloc_fn.
    • ncalloc_fn

      public static void ncalloc_fn(long struct, PointerBuffer value)
      Unsafe version of calloc_fn.
    • nfree_fn

      public static void nfree_fn(long struct, PointerBuffer value)
      Unsafe version of free_fn.
    • validate

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