Class ZSTDCustomMem

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class ZSTDCustomMem extends Struct<ZSTDCustomMem> implements NativeResource

 struct ZSTD_customMem {
     ZSTD_allocFunction customAlloc;
     ZSTD_freeFunction customFree;
     void * opaque;
 }
  • Field Details

    • SIZEOF

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

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

      public static final int CUSTOMALLOC
      The struct member offsets.
    • CUSTOMFREE

      public static final int CUSTOMFREE
      The struct member offsets.
    • OPAQUE

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

    • ZSTDCustomMem

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

      public ZSTDAllocFunction customAlloc()
      Returns:
      the value of the customAlloc field.
    • customFree

      public ZSTDFreeFunction customFree()
      Returns:
      the value of the customFree field.
    • opaque

      public long opaque()
      Returns:
      the value of the opaque field.
    • customAlloc

      public ZSTDCustomMem customAlloc(ZSTDAllocFunctionI value)
      Sets the specified value to the customAlloc field.
    • customFree

      public ZSTDCustomMem customFree(ZSTDFreeFunctionI value)
      Sets the specified value to the customFree field.
    • opaque

      public ZSTDCustomMem opaque(long value)
      Sets the specified value to the opaque field.
    • set

      public ZSTDCustomMem set(ZSTDAllocFunctionI customAlloc, ZSTDFreeFunctionI customFree, long opaque)
      Initializes this struct with the specified values.
    • set

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static ZSTDAllocFunction ncustomAlloc(long struct)
      Unsafe version of customAlloc().
    • ncustomFree

      public static ZSTDFreeFunction ncustomFree(long struct)
      Unsafe version of customFree().
    • nopaque

      public static long nopaque(long struct)
      Unsafe version of opaque().
    • ncustomAlloc

      public static void ncustomAlloc(long struct, ZSTDAllocFunctionI value)
      Unsafe version of customAlloc.
    • ncustomFree

      public static void ncustomFree(long struct, ZSTDFreeFunctionI value)
      Unsafe version of customFree.
    • nopaque

      public static void nopaque(long struct, long value)
      Unsafe version of opaque.
    • validate

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