Functions | |
word_t | croc_memblock_new (CrocThread *t, uword_t len) |
word_t | croc_memblock_fromNativeArray (CrocThread *t, const void *arr, uword_t arrLen) |
word_t | croc_memblock_viewNativeArray (CrocThread *t, void *arr, uword_t arrLen) |
void | croc_memblock_reviewNativeArray (CrocThread *t, word_t slot, void *arr, uword_t arrLen) |
char * | croc_memblock_getData (CrocThread *t, word_t slot) |
char * | croc_memblock_getDatan (CrocThread *t, word_t slot, uword_t *len) |
int | croc_memblock_ownData (CrocThread *t, word_t slot) |
Functions which operate on memblocks.
word_t croc_memblock_new | ( | CrocThread * | t, |
uword_t | len | ||
) |
Creates and pushes a new memblock object that is len
bytes long.
word_t croc_memblock_fromNativeArray | ( | CrocThread * | t, |
const void * | arr, | ||
uword_t | arrLen | ||
) |
Creates and pushes a new memblock whose data is a copy of the given array.
arr | is the pointer to the array. |
arrLen | is the length of the array, in bytes. |
word_t croc_memblock_viewNativeArray | ( | CrocThread * | t, |
void * | arr, | ||
uword_t | arrLen | ||
) |
Creates and pushes a new memblock object that is a view of the given array.
The memblock will not own its data.
arr | is the pointer to the array. It is your responsibility to keep this array around as long as the memblock which views it exists. |
arrLen | is the length of the array, in bytes. |
void croc_memblock_reviewNativeArray | ( | CrocThread * | t, |
word_t | slot, | ||
void * | arr, | ||
uword_t | arrLen | ||
) |
Same as croc_memblock_viewNativeArray, except instead of creating a new memblock, it changes an existing memblock at slot
so that its data points to the native array.
If the memblock had any data (and owned it), that data will be freed.
arr | is the pointer to the array. It is your responsibility to keep this array around as long as the memblock which views it exists. |
arrLen | is the length of the array, in bytes. |
char* croc_memblock_getData | ( | CrocThread * | t, |
word_t | slot | ||
) |
Returns a pointer to the data of the memblock in the given slot
.
The pointer returned from this may point into Croc's memory (if the memblock owns its data). You are allowed to modify the data at this pointer, but don't store it unless you know the memblock won't be collected!
char* croc_memblock_getDatan | ( | CrocThread * | t, |
word_t | slot, | ||
uword_t * | len | ||
) |
Same as croc_memblock_getData, except it also returns the length of the memblock's data in bytes through the len
parameter.
The pointer returned from this may point into Croc's memory (if the memblock owns its data). You are allowed to modify the data at this pointer, but don't store it unless you know the memblock won't be collected!
int croc_memblock_ownData | ( | CrocThread * | t, |
word_t | slot | ||
) |
slot
owns its data (it is allocated on the Croc heap). If this returns 0, it means the memblock is a view of a native array.