Package org.lwjgl.system.libc
Class LibCStdlib
- java.lang.Object
-
- org.lwjgl.system.libc.LibCStdlib
-
public class LibCStdlib extends java.lang.Object
Native bindings to stdlib.h.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.nio.ByteBuffer
aligned_alloc(long alignment, long size)
Allocatessize
bytes of uninitialized storage whose alignment is specified byalignment
.static void
aligned_free(java.nio.ByteBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(java.nio.DoubleBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(java.nio.FloatBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(java.nio.IntBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(java.nio.LongBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(PointerBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static void
aligned_free(java.nio.ShortBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
.static java.nio.ByteBuffer
calloc(long nmemb, long size)
Allocates memory for an array ofnmemb
elements ofsize
bytes each and returns a pointer to the allocated memory.static void
free(java.nio.ByteBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(java.nio.DoubleBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(java.nio.FloatBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(java.nio.IntBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(java.nio.LongBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(PointerBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static void
free(java.nio.ShortBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
.static java.nio.ByteBuffer
malloc(long size)
Allocatessize
bytes and returns a pointer to the allocated memory.static java.nio.ByteBuffer
realloc(java.nio.ByteBuffer ptr, long size)
Changes the size of the memory block pointed to byptr
tosize
bytes The contents will be unchanged in the range from the start of the region up to the minimum of the old and new sizes.
-
-
-
Method Detail
-
malloc
public static java.nio.ByteBuffer malloc(long size)
Allocatessize
bytes and returns a pointer to the allocated memory. The memory is not initialized. Ifsize
is 0, then malloc() returns eitherNULL
, or a unique pointer value that can later be successfully passed toLibCStdlib.free(java.nio.ByteBuffer)
.- Parameters:
size
- the number of bytes to allocate
-
calloc
public static java.nio.ByteBuffer calloc(long nmemb, long size)
Allocates memory for an array ofnmemb
elements ofsize
bytes each and returns a pointer to the allocated memory. The memory is set to zero. Ifnmemb
orsize
is 0, then calloc() returns eitherNULL
, or a unique pointer value that can later be successfully passed toLibCStdlib.free(java.nio.ByteBuffer)
.- Parameters:
nmemb
- the number of elements to allocatesize
- the number of bytes to allocate per element
-
realloc
public static java.nio.ByteBuffer realloc(java.nio.ByteBuffer ptr, long size)
Changes the size of the memory block pointed to byptr
tosize
bytes The contents will be unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size is larger than the old size, the added memory will not be initialized. Ifptr
isNULL
, then the call is equivalent tomalloc(size)
, for all values ofsize
; ifsize
is equal to zero, andptr
is notNULL
, then the call is equivalent tofree(ptr)
. Unlessptr
isNULL
, it must have been returned by an earlier call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
orLibCStdlib.realloc(java.nio.ByteBuffer, long)
. If the area pointed to was moved, afree(ptr)
is done.- Parameters:
ptr
- the memory block to reallocatesize
- the new memory block size, in bytes
-
free
public static void free(java.nio.ByteBuffer ptr) public static void free(java.nio.ShortBuffer ptr) public static void free(java.nio.IntBuffer ptr) public static void free(java.nio.LongBuffer ptr) public static void free(java.nio.FloatBuffer ptr) public static void free(java.nio.DoubleBuffer ptr) public static void free(PointerBuffer ptr)
Frees the memory space pointed to byptr
, which must have been returned by a previous call toLibCStdlib.malloc(long)
,LibCStdlib.calloc(long, long)
, orLibCStdlib.realloc(java.nio.ByteBuffer, long)
. Otherwise, or iffree(ptr)
has already been called before, undefined behavior occurs. If ptr isNULL
, no operation is performed.- Parameters:
ptr
- the memory space to free
-
aligned_alloc
public static java.nio.ByteBuffer aligned_alloc(long alignment, long size)
Allocatessize
bytes of uninitialized storage whose alignment is specified byalignment
. The size parameter must be an integral multiple of alignment. Memory allocated with aligned_alloc() must be freed withLibCStdlib.aligned_free(java.nio.ByteBuffer)
.- Parameters:
alignment
- the alignment. Must be a power of two value.size
- the number of bytes to allocate. Must be a multiple ofalignment
.
-
aligned_free
public static void aligned_free(java.nio.ByteBuffer ptr) public static void aligned_free(java.nio.ShortBuffer ptr) public static void aligned_free(java.nio.IntBuffer ptr) public static void aligned_free(java.nio.LongBuffer ptr) public static void aligned_free(java.nio.FloatBuffer ptr) public static void aligned_free(java.nio.DoubleBuffer ptr) public static void aligned_free(PointerBuffer ptr)
Frees a block of memory that was allocated withLibCStdlib.aligned_alloc(long, long)
. If ptr isNULL
, no operation is performed.- Parameters:
ptr
- the aligned block of memory to free
-
-