Class MemoryStack
- All Implemented Interfaces:
AutoCloseable
,Pointer
This class should be used in a thread-local manner for stack allocations.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.lwjgl.system.Pointer
Pointer.Default
-
Field Summary
Fields inherited from interface org.lwjgl.system.Pointer
BITS32, BITS64, CLONG_SHIFT, CLONG_SIZE, POINTER_SHIFT, POINTER_SIZE
-
Method Summary
Modifier and TypeMethodDescriptionASCII
(CharSequence text) Encodes the specified text on the stack using ASCII encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.ASCII
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using ASCII encoding and returns aByteBuffer
that points to the encoded text.ASCIISafe
(CharSequence text) ASCIISafe
(CharSequence text, boolean nullTerminated) bytes
(byte x) Single value version ofmalloc(int, int)
.bytes
(byte... values) Vararg version ofmalloc(int, int)
.bytes
(byte x, byte y) Two value version ofmalloc(int, int)
.bytes
(byte x, byte y, byte z) Three value version ofmalloc(int, int)
.bytes
(byte x, byte y, byte z, byte w) Four value version ofmalloc(int, int)
.calloc
(int size) Calloc version ofmalloc(int)
.calloc
(int alignment, int size) Calloc version ofmalloc(int, int)
.callocCLong
(int size) CLong version ofcalloc(int)
.callocDouble
(int size) Double version ofcalloc(int)
.callocFloat
(int size) Float version ofcalloc(int)
.callocInt
(int size) Int version ofcalloc(int)
.callocLong
(int size) Long version ofcalloc(int)
.callocPointer
(int size) Pointer version ofcalloc(int)
.callocShort
(int size) Short version ofcalloc(int)
.clongs
(long x) Single value version ofmallocCLong(int)
.clongs
(long... values) Vararg version ofmallocCLong(int)
.clongs
(long x, long y) Two value version ofmallocCLong(int)
.clongs
(long x, long y, long z) Three value version ofmallocCLong(int)
.clongs
(long x, long y, long z, long w) Four value version ofmallocCLong(int)
.void
close()
Callspop()
on thisMemoryStack
.static MemoryStack
create()
Creates a newMemoryStack
with the default size.static MemoryStack
create
(int capacity) Creates a newMemoryStack
with the specified size.static MemoryStack
create
(ByteBuffer buffer) Creates a newMemoryStack
backed by the specified memory buffer.doubles
(double x) Single value version ofmallocDouble(int)
.doubles
(double... values) Vararg version ofmallocDouble(int)
.doubles
(double x, double y) Two value version ofmallocDouble(int)
.doubles
(double x, double y, double z) Three value version ofmallocDouble(int)
.doubles
(double x, double y, double z, double w) Four value version ofmallocDouble(int)
.floats
(float x) Single value version ofmallocFloat(int)
.floats
(float... values) Vararg version ofmallocFloat(int)
.floats
(float x, float y) Two value version ofmallocFloat(int)
.floats
(float x, float y, float z) Three value version ofmallocFloat(int)
.floats
(float x, float y, float z, float w) Four value version ofmallocFloat(int)
.long
Returns the address of the backing off-heap memory.int
Returns the current frame index.int
Returns the current stack pointer.long
Returns the memory address at the current stack pointer.int
getSize()
Returns the size of the backing off-heap memory.ints
(int x) Single value version ofmallocInt(int)
.ints
(int... values) Vararg version ofmallocInt(int)
.ints
(int x, int y) Two value version ofmallocInt(int)
.ints
(int x, int y, int z) Three value version ofmallocInt(int)
.ints
(int x, int y, int z, int w) Four value version ofmallocInt(int)
.longs
(long x) Single value version ofmallocLong(int)
.longs
(long... more) Vararg version ofmallocLong(int)
.longs
(long x, long y) Two value version ofmallocLong(int)
.longs
(long x, long y, long z) Three value version ofmallocLong(int)
.longs
(long x, long y, long z, long w) Four value version ofmallocLong(int)
.malloc
(int size) malloc
(int alignment, int size) Allocates an alignedByteBuffer
on the stack.mallocCLong
(int size) CLong version ofmalloc(int)
.mallocDouble
(int size) Double version ofmalloc(int)
.mallocFloat
(int size) Float version ofmalloc(int)
.mallocInt
(int size) Int version ofmalloc(int)
.mallocLong
(int size) Long version ofmalloc(int)
.mallocPointer
(int size) Pointer version ofmalloc(int)
.mallocShort
(int size) Short version ofmalloc(int)
.int
nASCII
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using ASCII encoding and returns the encoded text length, in bytes.int
nASCIISafe
(CharSequence text, boolean nullTerminated) long
nbyte
(byte value) Unsafe version ofbytes(byte)
.long
ncalloc
(int alignment, int num, int size) Allocates a block of memory on the stack for an array ofnum
elements, each of themsize
bytes long, and initializes all its bits to zero.long
nclong
(long value) Unsafe version ofclongs(long)
.static MemoryStack
ncreate
(long address, int size) Creates a newMemoryStack
backed by the specified memory region.long
ndouble
(double value) Unsafe version ofdoubles(double)
.long
nfloat
(float value) Unsafe version offloats(float)
.long
nint
(int value) Unsafe version ofints(int)
.long
nlong
(long value) Unsafe version oflongs(long)
.long
nmalloc
(int size) long
nmalloc
(int alignment, int size) Allocates a block ofsize
bytes of memory on the stack.long
npointer
(long value) Unsafe version ofpointers(long)
.long
Unsafe version ofpointers(Buffer)
.long
Unsafe version ofpointers(Pointer)
.long
nshort
(short value) Unsafe version ofshorts(short)
.static long
nstackCalloc
(int alignment, int num, int size) Thread-local version ofncalloc(int, int, int)
.static long
nstackMalloc
(int size) Thread-local version ofnmalloc(int)
.static long
nstackMalloc
(int alignment, int size) Thread-local version ofnmalloc(int, int)
.int
nUTF16
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using UTF16 encoding and returns the encoded text length, in bytes.int
nUTF16Safe
(CharSequence text, boolean nullTerminated) int
nUTF8
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using UTF8 encoding and returns the encoded text length, in bytes.int
nUTF8Safe
(CharSequence text, boolean nullTerminated) pointers
(long x) Single value version ofmallocPointer(int)
.pointers
(long... values) Vararg version ofmallocPointer(int)
.pointers
(long x, long y) Two value version ofmallocPointer(int)
.pointers
(long x, long y, long z) Three value version ofmallocPointer(int)
.pointers
(long x, long y, long z, long w) Four value version ofmallocPointer(int)
.Single value version ofmallocPointer(int)
.Vararg version ofmallocPointer(int)
.Two value version ofmallocPointer(int)
.Three value version ofmallocPointer(int)
.Four value version ofmallocPointer(int)
.Single value version ofmallocPointer(int)
.Vararg version ofmallocPointer(int)
.Two value version ofmallocPointer(int)
.Three value version ofmallocPointer(int)
.Four value version ofmallocPointer(int)
.pointersOfElements
(CustomBuffer<?> buffer) Allocates a newPointerBuffer
of sizebuffer.remaining()
and fills it with the addresses of the values within the providedCustomBuffer
starting atbuffer.position()
.pop()
Pops the current stack frame and moves the stack pointer to the end of the previous stack frame.push()
Stores the current stack pointer and pushes a new frame to the stack.void
setPointer
(int pointer) Sets the current stack pointer.shorts
(short x) Single value version ofmallocShort(int)
.shorts
(short... values) Vararg version ofmallocShort(int)
.shorts
(short x, short y) Two value version ofmallocShort(int)
.shorts
(short x, short y, short z) Three value version ofmallocShort(int)
.shorts
(short x, short y, short z, short w) Four value version ofmallocShort(int)
.static ByteBuffer
stackASCII
(CharSequence text) Thread-local version ofASCII(CharSequence)
.static ByteBuffer
stackASCII
(CharSequence text, boolean nullTerminated) Thread-local version ofASCII(CharSequence, boolean)
.static ByteBuffer
stackASCIISafe
(CharSequence text) Thread-local version ofASCII(CharSequence)
.static ByteBuffer
stackASCIISafe
(CharSequence text, boolean nullTerminated) Thread-local version ofASCII(CharSequence, boolean)
.static ByteBuffer
stackBytes
(byte x) Thread-local version ofbytes(byte)
.static ByteBuffer
stackBytes
(byte... values) Thread-local version ofbytes(byte...)
.static ByteBuffer
stackBytes
(byte x, byte y) Thread-local version ofbytes(byte, byte)
.static ByteBuffer
stackBytes
(byte x, byte y, byte z) Thread-local version ofbytes(byte, byte, byte)
.static ByteBuffer
stackBytes
(byte x, byte y, byte z, byte w) Thread-local version ofbytes(byte, byte, byte, byte)
.static ByteBuffer
stackCalloc
(int size) Thread-local version ofcalloc
.static CLongBuffer
stackCallocCLong
(int size) Thread-local version ofcallocCLong(int)
.static DoubleBuffer
stackCallocDouble
(int size) Thread-local version ofcallocDouble(int)
.static FloatBuffer
stackCallocFloat
(int size) Thread-local version ofcallocFloat(int)
.static IntBuffer
stackCallocInt
(int size) Thread-local version ofcallocInt(int)
.static LongBuffer
stackCallocLong
(int size) Thread-local version ofcallocLong(int)
.static PointerBuffer
stackCallocPointer
(int size) Thread-local version ofcallocPointer(int)
.static ShortBuffer
stackCallocShort
(int size) Thread-local version ofcallocShort(int)
.static CLongBuffer
stackCLongs
(long x) Thread-local version oflongs(long)
.static CLongBuffer
stackCLongs
(long... values) Thread-local version oflongs(long...)
.static CLongBuffer
stackCLongs
(long x, long y) Thread-local version oflongs(long, long)
.static CLongBuffer
stackCLongs
(long x, long y, long z) Thread-local version oflongs(long, long, long)
.static CLongBuffer
stackCLongs
(long x, long y, long z, long w) Thread-local version oflongs(long, long, long, long)
.static DoubleBuffer
stackDoubles
(double x) Thread-local version ofdoubles(double)
.static DoubleBuffer
stackDoubles
(double... values) Thread-local version ofdoubles(double...)
.static DoubleBuffer
stackDoubles
(double x, double y) Thread-local version ofdoubles(double, double)
.static DoubleBuffer
stackDoubles
(double x, double y, double z) Thread-local version ofdoubles(double, double, double)
.static DoubleBuffer
stackDoubles
(double x, double y, double z, double w) Thread-local version ofdoubles(double, double, double, double)
.static FloatBuffer
stackFloats
(float x) Thread-local version offloats(float)
.static FloatBuffer
stackFloats
(float... values) Thread-local version offloats(float...)
.static FloatBuffer
stackFloats
(float x, float y) Thread-local version offloats(float, float)
.static FloatBuffer
stackFloats
(float x, float y, float z) Thread-local version offloats(float, float, float)
.static FloatBuffer
stackFloats
(float x, float y, float z, float w) Thread-local version offloats(float, float, float, float)
.static MemoryStack
stackGet()
Returns the stack of the current thread.static IntBuffer
stackInts
(int x) Thread-local version ofints(int)
.static IntBuffer
stackInts
(int... values) Thread-local version ofints(int...)
.static IntBuffer
stackInts
(int x, int y) Thread-local version ofints(int, int)
.static IntBuffer
stackInts
(int x, int y, int z) Thread-local version ofints(int, int, int)
.static IntBuffer
stackInts
(int x, int y, int z, int w) Thread-local version ofints(int, int, int, int)
.static LongBuffer
stackLongs
(long x) Thread-local version oflongs(long)
.static LongBuffer
stackLongs
(long... values) Thread-local version oflongs(long...)
.static LongBuffer
stackLongs
(long x, long y) Thread-local version oflongs(long, long)
.static LongBuffer
stackLongs
(long x, long y, long z) Thread-local version oflongs(long, long, long)
.static LongBuffer
stackLongs
(long x, long y, long z, long w) Thread-local version oflongs(long, long, long, long)
.static ByteBuffer
stackMalloc
(int size) Thread-local version ofmalloc
.static CLongBuffer
stackMallocCLong
(int size) Thread-local version ofmallocCLong(int)
.static DoubleBuffer
stackMallocDouble
(int size) Thread-local version ofmallocDouble(int)
.static FloatBuffer
stackMallocFloat
(int size) Thread-local version ofmallocFloat(int)
.static IntBuffer
stackMallocInt
(int size) Thread-local version ofmallocInt(int)
.static LongBuffer
stackMallocLong
(int size) Thread-local version ofmallocLong(int)
.static PointerBuffer
stackMallocPointer
(int size) Thread-local version ofmallocPointer(int)
.static ShortBuffer
stackMallocShort
(int size) Thread-local version ofmallocShort(int)
.static PointerBuffer
stackPointers
(long x) Thread-local version ofpointers(long)
.static PointerBuffer
stackPointers
(long... values) Thread-local version ofpointers(long...)
.static PointerBuffer
stackPointers
(long x, long y) Thread-local version ofpointers(long, long)
.static PointerBuffer
stackPointers
(long x, long y, long z) Thread-local version ofpointers(long, long, long)
.static PointerBuffer
stackPointers
(long x, long y, long z, long w) Thread-local version ofpointers(long, long, long, long)
.static PointerBuffer
Thread-local version ofpointers(Pointer)
.static PointerBuffer
stackPointers
(Pointer... values) Thread-local version ofpointers(Pointer...)
.static PointerBuffer
stackPointers
(Pointer x, Pointer y) Thread-local version ofpointers(Pointer, Pointer)
.static PointerBuffer
stackPointers
(Pointer x, Pointer y, Pointer z) Thread-local version ofpointers(Pointer, Pointer, Pointer)
.static PointerBuffer
stackPointers
(Pointer x, Pointer y, Pointer z, Pointer w) Thread-local version ofpointers(Pointer, Pointer, Pointer, Pointer)
.static MemoryStack
stackPop()
Callspop()
on the stack of the current thread.static MemoryStack
Callspush()
on the stack of the current thread.static ShortBuffer
stackShorts
(short x) Thread-local version ofshorts(short)
.static ShortBuffer
stackShorts
(short... values) Thread-local version ofshorts(short...)
.static ShortBuffer
stackShorts
(short x, short y) Thread-local version ofshorts(short, short)
.static ShortBuffer
stackShorts
(short x, short y, short z) Thread-local version ofshorts(short, short, short)
.static ShortBuffer
stackShorts
(short x, short y, short z, short w) Thread-local version ofshorts(short, short, short, short)
.static ByteBuffer
stackUTF16
(CharSequence text) Thread-local version ofUTF16(CharSequence)
.static ByteBuffer
stackUTF16
(CharSequence text, boolean nullTerminated) Thread-local version ofUTF16(CharSequence, boolean)
.static ByteBuffer
stackUTF16Safe
(CharSequence text) Thread-local version ofUTF16(CharSequence)
.static ByteBuffer
stackUTF16Safe
(CharSequence text, boolean nullTerminated) Thread-local version ofUTF16(CharSequence, boolean)
.static ByteBuffer
stackUTF8
(CharSequence text) Thread-local version ofUTF8(CharSequence)
.static ByteBuffer
stackUTF8
(CharSequence text, boolean nullTerminated) Thread-local version ofUTF8(CharSequence, boolean)
.static ByteBuffer
stackUTF8Safe
(CharSequence text) Thread-local version ofUTF8(CharSequence)
.static ByteBuffer
stackUTF8Safe
(CharSequence text, boolean nullTerminated) Thread-local version ofUTF8(CharSequence, boolean)
.UTF16
(CharSequence text) Encodes the specified text on the stack using UTF16 encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.UTF16
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using UTF16 encoding and returns aByteBuffer
that points to the encoded text.UTF16Safe
(CharSequence text) UTF16Safe
(CharSequence text, boolean nullTerminated) UTF8
(CharSequence text) Encodes the specified text on the stack using UTF8 encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.UTF8
(CharSequence text, boolean nullTerminated) Encodes the specified text on the stack using UTF8 encoding and returns aByteBuffer
that points to the encoded text.UTF8Safe
(CharSequence text) UTF8Safe
(CharSequence text, boolean nullTerminated) Methods inherited from class org.lwjgl.system.Pointer.Default
address, equals, hashCode, toString
-
Method Details
-
create
Creates a newMemoryStack
with the default size.In the initial state, there is no active stack frame. The
push()
method must be used before any allocations. -
create
Creates a newMemoryStack
with the specified size.In the initial state, there is no active stack frame. The
push()
method must be used before any allocations.- Parameters:
capacity
- the maximum number of bytes that may be allocated on the stack
-
create
Creates a newMemoryStack
backed by the specified memory buffer.In the initial state, there is no active stack frame. The
push()
method must be used before any allocations.- Parameters:
buffer
- the backing memory buffer
-
ncreate
Creates a newMemoryStack
backed by the specified memory region.In the initial state, there is no active stack frame. The
push()
method must be used before any allocations.- Parameters:
address
- the backing memory addresssize
- the backing memory size
-
push
Stores the current stack pointer and pushes a new frame to the stack.This method should be called when entering a method, before doing any stack allocations. When exiting a method, call the
pop()
method to restore the previous stack frame.Pairs of push/pop calls may be nested. Care must be taken to:
- match every push with a pop
- not call pop before push has been called at least once
- not nest push calls to more than the maximum supported depth
- Returns:
- this stack
-
pop
Pops the current stack frame and moves the stack pointer to the end of the previous stack frame.- Returns:
- this stack
-
close
public void close()Callspop()
on thisMemoryStack
.This method should not be used directly. It is called automatically when the
MemoryStack
is used as a resource in a try-with-resources statement.- Specified by:
close
in interfaceAutoCloseable
-
getAddress
public long getAddress()Returns the address of the backing off-heap memory.The stack grows "downwards", so the bottom of the stack is at
address + size
, while the top is ataddress
. -
getSize
public int getSize()Returns the size of the backing off-heap memory.This is the maximum number of bytes that may be allocated on the stack.
-
getFrameIndex
public int getFrameIndex()Returns the current frame index.This is the current number of nested
push()
calls. -
getPointerAddress
public long getPointerAddress()Returns the memory address at the current stack pointer. -
getPointer
public int getPointer()Returns the current stack pointer.The stack grows "downwards", so when the stack is empty
pointer
is equal tosize
. On every allocationpointer
is reduced by the allocated size (after alignment) andaddress + pointer
points to the first byte of the last allocation.Effectively, this methods returns how many more bytes may be allocated on the stack.
-
setPointer
public void setPointer(int pointer) Sets the current stack pointer.This method directly manipulates the stack pointer. Using it irresponsibly may break the internal state of the stack. It should only be used in rare cases or in auto-generated code.
-
nmalloc
public long nmalloc(int size) - Parameters:
size
- the allocation size- Returns:
- the memory address on the stack for the requested allocation
-
nmalloc
public long nmalloc(int alignment, int size) Allocates a block ofsize
bytes of memory on the stack. The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.- Parameters:
alignment
- the required alignmentsize
- the allocation size- Returns:
- the memory address on the stack for the requested allocation
-
ncalloc
public long ncalloc(int alignment, int num, int size) Allocates a block of memory on the stack for an array ofnum
elements, each of themsize
bytes long, and initializes all its bits to zero.- Parameters:
alignment
- the required element alignmentnum
- num the number of elements to allocatesize
- the size of each element- Returns:
- the memory address on the stack for the requested allocation
-
malloc
Allocates an alignedByteBuffer
on the stack.- Parameters:
alignment
- the required buffer alignmentsize
- the number of elements in the buffer- Returns:
- the allocated buffer
-
calloc
Calloc version ofmalloc(int, int)
. -
malloc
- Parameters:
size
- the number of elements in the buffer- Returns:
- the allocated buffer
-
calloc
Calloc version ofmalloc(int)
. -
nbyte
public long nbyte(byte value) Unsafe version ofbytes(byte)
. -
bytes
Single value version ofmalloc(int, int)
. -
bytes
Two value version ofmalloc(int, int)
. -
bytes
Three value version ofmalloc(int, int)
. -
bytes
Four value version ofmalloc(int, int)
. -
bytes
Vararg version ofmalloc(int, int)
. -
mallocShort
Short version ofmalloc(int)
. -
callocShort
Short version ofcalloc(int)
. -
nshort
public long nshort(short value) Unsafe version ofshorts(short)
. -
shorts
Single value version ofmallocShort(int)
. -
shorts
Two value version ofmallocShort(int)
. -
shorts
Three value version ofmallocShort(int)
. -
shorts
Four value version ofmallocShort(int)
. -
shorts
Vararg version ofmallocShort(int)
. -
mallocInt
Int version ofmalloc(int)
. -
callocInt
Int version ofcalloc(int)
. -
nint
public long nint(int value) Unsafe version ofints(int)
. -
ints
Single value version ofmallocInt(int)
. -
ints
Two value version ofmallocInt(int)
. -
ints
Three value version ofmallocInt(int)
. -
ints
Four value version ofmallocInt(int)
. -
ints
Vararg version ofmallocInt(int)
. -
mallocLong
Long version ofmalloc(int)
. -
callocLong
Long version ofcalloc(int)
. -
nlong
public long nlong(long value) Unsafe version oflongs(long)
. -
longs
Single value version ofmallocLong(int)
. -
longs
Two value version ofmallocLong(int)
. -
longs
Three value version ofmallocLong(int)
. -
longs
Four value version ofmallocLong(int)
. -
longs
Vararg version ofmallocLong(int)
. -
mallocCLong
CLong version ofmalloc(int)
. -
callocCLong
CLong version ofcalloc(int)
. -
nclong
public long nclong(long value) Unsafe version ofclongs(long)
. -
clongs
Single value version ofmallocCLong(int)
. -
clongs
Two value version ofmallocCLong(int)
. -
clongs
Three value version ofmallocCLong(int)
. -
clongs
Four value version ofmallocCLong(int)
. -
clongs
Vararg version ofmallocCLong(int)
. -
mallocFloat
Float version ofmalloc(int)
. -
callocFloat
Float version ofcalloc(int)
. -
nfloat
public long nfloat(float value) Unsafe version offloats(float)
. -
floats
Single value version ofmallocFloat(int)
. -
floats
Two value version ofmallocFloat(int)
. -
floats
Three value version ofmallocFloat(int)
. -
floats
Four value version ofmallocFloat(int)
. -
floats
Vararg version ofmallocFloat(int)
. -
mallocDouble
Double version ofmalloc(int)
. -
callocDouble
Double version ofcalloc(int)
. -
ndouble
public long ndouble(double value) Unsafe version ofdoubles(double)
. -
doubles
Single value version ofmallocDouble(int)
. -
doubles
Two value version ofmallocDouble(int)
. -
doubles
Three value version ofmallocDouble(int)
. -
doubles
Four value version ofmallocDouble(int)
. -
doubles
Vararg version ofmallocDouble(int)
. -
mallocPointer
Pointer version ofmalloc(int)
. -
callocPointer
Pointer version ofcalloc(int)
. -
npointer
public long npointer(long value) Unsafe version ofpointers(long)
. -
pointers
Single value version ofmallocPointer(int)
. -
pointers
Two value version ofmallocPointer(int)
. -
pointers
Three value version ofmallocPointer(int)
. -
pointers
Four value version ofmallocPointer(int)
. -
pointers
Vararg version ofmallocPointer(int)
. -
npointer
Unsafe version ofpointers(Pointer)
. -
pointers
Single value version ofmallocPointer(int)
. -
pointers
Two value version ofmallocPointer(int)
. -
pointers
Three value version ofmallocPointer(int)
. -
pointers
Four value version ofmallocPointer(int)
. -
pointers
Vararg version ofmallocPointer(int)
. -
npointer
Unsafe version ofpointers(Buffer)
. -
pointers
Single value version ofmallocPointer(int)
. -
pointers
Two value version ofmallocPointer(int)
. -
pointers
Three value version ofmallocPointer(int)
. -
pointers
Four value version ofmallocPointer(int)
. -
pointers
Vararg version ofmallocPointer(int)
. -
pointersOfElements
Allocates a newPointerBuffer
of sizebuffer.remaining()
and fills it with the addresses of the values within the providedCustomBuffer
starting atbuffer.position()
.- Parameters:
buffer
- theCustomBuffer
to obtain its element addresses of- Returns:
- a
PointerBuffer
containing the buffer's element addresses
-
ASCII
Encodes the specified text on the stack using ASCII encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encode
-
ASCII
Encodes the specified text on the stack using ASCII encoding and returns aByteBuffer
that points to the encoded text.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
nASCII
Encodes the specified text on the stack using ASCII encoding and returns the encoded text length, in bytes.Use
getPointerAddress()
immediately after this method to get the encoded text address, which will havealignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
ASCIISafe
-
ASCIISafe
-
nASCIISafe
-
UTF8
Encodes the specified text on the stack using UTF8 encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encode
-
UTF8
Encodes the specified text on the stack using UTF8 encoding and returns aByteBuffer
that points to the encoded text.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
nUTF8
Encodes the specified text on the stack using UTF8 encoding and returns the encoded text length, in bytes.Use
getPointerAddress()
immediately after this method to get the encoded text address, which will havealignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
UTF8Safe
-
UTF8Safe
-
nUTF8Safe
-
UTF16
Encodes the specified text on the stack using UTF16 encoding and returns aByteBuffer
that points to the encoded text, including a null-terminator.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encode
-
UTF16
Encodes the specified text on the stack using UTF16 encoding and returns aByteBuffer
that points to the encoded text.The buffer will have
alignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
nUTF16
Encodes the specified text on the stack using UTF16 encoding and returns the encoded text length, in bytes.Use
getPointerAddress()
immediately after this method to get the encoded text address, which will havealignment
equal toPOINTER_SIZE
.- Parameters:
text
- the text to encodenullTerminated
- if true, a null-terminator is included at the end of the encoded text
-
UTF16Safe
-
UTF16Safe
-
nUTF16Safe
-
stackGet
Returns the stack of the current thread. -
stackPush
Callspush()
on the stack of the current thread.- Returns:
- the stack of the current thread.
-
stackPop
Callspop()
on the stack of the current thread.- Returns:
- the stack of the current thread.
-
nstackMalloc
public static long nstackMalloc(int size) Thread-local version ofnmalloc(int)
. -
nstackMalloc
public static long nstackMalloc(int alignment, int size) Thread-local version ofnmalloc(int, int)
. -
nstackCalloc
public static long nstackCalloc(int alignment, int num, int size) Thread-local version ofncalloc(int, int, int)
. -
stackMalloc
Thread-local version ofmalloc
. -
stackCalloc
Thread-local version ofcalloc
. -
stackBytes
Thread-local version ofbytes(byte)
. -
stackBytes
Thread-local version ofbytes(byte, byte)
. -
stackBytes
Thread-local version ofbytes(byte, byte, byte)
. -
stackBytes
Thread-local version ofbytes(byte, byte, byte, byte)
. -
stackBytes
Thread-local version ofbytes(byte...)
. -
stackMallocShort
Thread-local version ofmallocShort(int)
. -
stackCallocShort
Thread-local version ofcallocShort(int)
. -
stackShorts
Thread-local version ofshorts(short)
. -
stackShorts
Thread-local version ofshorts(short, short)
. -
stackShorts
Thread-local version ofshorts(short, short, short)
. -
stackShorts
Thread-local version ofshorts(short, short, short, short)
. -
stackShorts
Thread-local version ofshorts(short...)
. -
stackMallocInt
Thread-local version ofmallocInt(int)
. -
stackCallocInt
Thread-local version ofcallocInt(int)
. -
stackInts
Thread-local version ofints(int)
. -
stackInts
Thread-local version ofints(int, int)
. -
stackInts
Thread-local version ofints(int, int, int)
. -
stackInts
Thread-local version ofints(int, int, int, int)
. -
stackInts
Thread-local version ofints(int...)
. -
stackMallocLong
Thread-local version ofmallocLong(int)
. -
stackCallocLong
Thread-local version ofcallocLong(int)
. -
stackLongs
Thread-local version oflongs(long)
. -
stackLongs
Thread-local version oflongs(long, long)
. -
stackLongs
Thread-local version oflongs(long, long, long)
. -
stackLongs
Thread-local version oflongs(long, long, long, long)
. -
stackLongs
Thread-local version oflongs(long...)
. -
stackMallocCLong
Thread-local version ofmallocCLong(int)
. -
stackCallocCLong
Thread-local version ofcallocCLong(int)
. -
stackCLongs
Thread-local version oflongs(long)
. -
stackCLongs
Thread-local version oflongs(long, long)
. -
stackCLongs
Thread-local version oflongs(long, long, long)
. -
stackCLongs
Thread-local version oflongs(long, long, long, long)
. -
stackCLongs
Thread-local version oflongs(long...)
. -
stackMallocFloat
Thread-local version ofmallocFloat(int)
. -
stackCallocFloat
Thread-local version ofcallocFloat(int)
. -
stackFloats
Thread-local version offloats(float)
. -
stackFloats
Thread-local version offloats(float, float)
. -
stackFloats
Thread-local version offloats(float, float, float)
. -
stackFloats
Thread-local version offloats(float, float, float, float)
. -
stackFloats
Thread-local version offloats(float...)
. -
stackMallocDouble
Thread-local version ofmallocDouble(int)
. -
stackCallocDouble
Thread-local version ofcallocDouble(int)
. -
stackDoubles
Thread-local version ofdoubles(double)
. -
stackDoubles
Thread-local version ofdoubles(double, double)
. -
stackDoubles
Thread-local version ofdoubles(double, double, double)
. -
stackDoubles
Thread-local version ofdoubles(double, double, double, double)
. -
stackDoubles
Thread-local version ofdoubles(double...)
. -
stackMallocPointer
Thread-local version ofmallocPointer(int)
. -
stackCallocPointer
Thread-local version ofcallocPointer(int)
. -
stackPointers
Thread-local version ofpointers(long)
. -
stackPointers
Thread-local version ofpointers(long, long)
. -
stackPointers
Thread-local version ofpointers(long, long, long)
. -
stackPointers
Thread-local version ofpointers(long, long, long, long)
. -
stackPointers
Thread-local version ofpointers(long...)
. -
stackPointers
Thread-local version ofpointers(Pointer)
. -
stackPointers
Thread-local version ofpointers(Pointer, Pointer)
. -
stackPointers
Thread-local version ofpointers(Pointer, Pointer, Pointer)
. -
stackPointers
Thread-local version ofpointers(Pointer, Pointer, Pointer, Pointer)
. -
stackPointers
Thread-local version ofpointers(Pointer...)
. -
stackASCII
Thread-local version ofASCII(CharSequence)
. -
stackASCII
Thread-local version ofASCII(CharSequence, boolean)
. -
stackUTF8
Thread-local version ofUTF8(CharSequence)
. -
stackUTF8
Thread-local version ofUTF8(CharSequence, boolean)
. -
stackUTF16
Thread-local version ofUTF16(CharSequence)
. -
stackUTF16
Thread-local version ofUTF16(CharSequence, boolean)
. -
stackASCIISafe
Thread-local version ofASCII(CharSequence)
. -
stackASCIISafe
@Nullable public static ByteBuffer stackASCIISafe(@Nullable CharSequence text, boolean nullTerminated) Thread-local version ofASCII(CharSequence, boolean)
. -
stackUTF8Safe
Thread-local version ofUTF8(CharSequence)
. -
stackUTF8Safe
@Nullable public static ByteBuffer stackUTF8Safe(@Nullable CharSequence text, boolean nullTerminated) Thread-local version ofUTF8(CharSequence, boolean)
. -
stackUTF16Safe
Thread-local version ofUTF16(CharSequence)
. -
stackUTF16Safe
@Nullable public static ByteBuffer stackUTF16Safe(@Nullable CharSequence text, boolean nullTerminated) Thread-local version ofUTF16(CharSequence, boolean)
.
-