Class FT_Memory

All Implemented Interfaces:
AutoCloseable, NativeResource, Pointer

public class FT_Memory extends Struct<FT_Memory> implements NativeResource

 struct FT_MemoryRec_ {
     void * user;
     {@link FT_Alloc_FuncI FT_Alloc_Func} alloc;
     {@link FT_Free_FuncI FT_Free_Func} free;
     {@link FT_Realloc_FuncI FT_Realloc_Func} realloc;
 }
  • Field Details

    • SIZEOF

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

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

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

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

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

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

    • FT_Memory

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

      public long user()
      Returns:
      the value of the user field.
    • alloc

      public @Nullable FT_Alloc_Func alloc()
      Returns:
      the value of the alloc field.
    • free$

      public @Nullable FT_Free_Func free$()
      Returns:
      the value of the free field.
    • realloc

      public @Nullable FT_Realloc_Func realloc()
      Returns:
      the value of the realloc field.
    • user

      public FT_Memory user(long value)
      Sets the specified value to the user field.
    • alloc

      public FT_Memory alloc(@Nullable FT_Alloc_FuncI value)
      Sets the specified value to the alloc field.
    • free$

      public FT_Memory free$(@Nullable FT_Free_FuncI value)
      Sets the specified value to the free field.
    • realloc

      public FT_Memory realloc(@Nullable FT_Realloc_FuncI value)
      Sets the specified value to the realloc field.
    • set

      public FT_Memory set(long user, FT_Alloc_FuncI alloc, FT_Free_FuncI free$, FT_Realloc_FuncI realloc)
      Initializes this struct with the specified values.
    • set

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      public static @Nullable FT_Alloc_Func nalloc(long struct)
      Unsafe version of alloc().
    • nfree$

      public static @Nullable FT_Free_Func nfree$(long struct)
      Unsafe version of free$().
    • nrealloc

      public static @Nullable FT_Realloc_Func nrealloc(long struct)
      Unsafe version of realloc().
    • nuser

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

      public static void nalloc(long struct, @Nullable FT_Alloc_FuncI value)
      Unsafe version of alloc.
    • nfree$

      public static void nfree$(long struct, @Nullable FT_Free_FuncI value)
      Unsafe version of free$.
    • nrealloc

      public static void nrealloc(long struct, @Nullable FT_Realloc_FuncI value)
      Unsafe version of realloc.