Functions | |
| void * | croc_mem_alloc (CrocThread *t, uword_t size) |
| void | croc_mem_resize (CrocThread *t, void **mem, uword_t *memSize, uword_t newSize) |
| void * | croc_mem_dup (CrocThread *t, void *mem, uword_t memSize) |
| void | croc_mem_free (CrocThread *t, void **mem, uword_t *memSize) |
Allocating and freeing arbitrary blocks of memory through a Croc VM.
| void* croc_mem_alloc | ( | CrocThread * | t, |
| uword_t | size | ||
| ) |
Allocates a block of memory through the Croc memory allocator, using the allocator function that the thread's VM was created with.
This is not garbage-collected; you are entirely responsible for managing this memory. It will, however, be tracked for memory leaks if the library was compiled with the CROC_LEAK_DETECTOR option.
| size | is the number of bytes to allocate. |
| void croc_mem_resize | ( | CrocThread * | t, |
| void ** | mem, | ||
| uword_t * | memSize, | ||
| uword_t | newSize | ||
| ) |
Resizes a block of memory that was allocated with croc_mem_alloc.
| [in,out] | mem | is the address of the pointer to the block to resize. This pointer may change as a result of resizing the block. |
| [in,out] | memSize | is the address of the existing size of the memory block. It will be changed to newSize. |
| newSize | is the new size of the memory block. |
| void* croc_mem_dup | ( | CrocThread * | t, |
| void * | mem, | ||
| uword_t | memSize | ||
| ) |
Duplicates a block of memory that was allocated with croc_mem_alloc.
The new memory block is the same size and contains the same data.
| void croc_mem_free | ( | CrocThread * | t, |
| void ** | mem, | ||
| uword_t * | memSize | ||
| ) |
Frees a block of memory that was allocated with croc_mem_alloc.
You must free every block that you allocated!
1.8.6