Macros | |
#define | AiMalloc(_size) AiMalloc_func(_size, __AI_FILE__, __AI_LINE__, __AI_FUNCTION__) |
#define | AiRealloc(_addr, _size) AiRealloc_func(_addr, _size, __AI_FILE__, __AI_LINE__, __AI_FUNCTION__) |
#define | AiFree(_addr) AiFree_func(_addr, __AI_FILE__, __AI_LINE__, __AI_FUNCTION__) |
Functions | |
AI_API void * | AiMalloc_func (size_t size, const char *file, int line, const char *func) |
Arnold malloc() wrapper. More... | |
AI_API void * | AiRealloc_func (void *addr, size_t size, const char *file, int line, const char *func) |
Arnold realloc() wrapper. More... | |
AI_API void | AiFree_func (void *addr, const char *file, int line, const char *func) |
Arnold free() wrapper. More... | |
AI_API void* AiMalloc_func | ( | size_t | size, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Arnold malloc()
wrapper.
Use this function just as you would use malloc()
to request a block of memory. If the size requested is 0, then return NULL. If the internal call to malloc()
returns NULL, which means there is not enough available memory for a block of that size, this function logs an error message with the source code location (file and line number) of the failed call. This is a very useful debugging tip that wouldn't be possible with a regular call to malloc()
.
To save some typing, Arnold provides a handy AiMalloc() macro. The following two lines of code are equivalent:
size | number of bytes to allocate |
file | filename of the compilation unit calling AiMalloc_func() |
line | line-number of the compilation unit calling AiMalloc_func() |
func | function the compilation unit calling AiMalloc_func() |
AI_API void* AiRealloc_func | ( | void * | addr, |
size_t | size, | ||
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Arnold realloc()
wrapper.
Checks for NULL and logs an error message. If the requested size is 0, then the address is freed instead. In practice, you will want to use the associated shortcut macro AiRealloc().
addr | the address of the memory block to resize |
size | number of bytes to allocate |
file | filename of the compilation unit calling AiRealloc_func() |
line | line-number of the compilation unit calling AiRealloc_func() |
func | function of the compilation unit calling AiRealloc_func() |
AI_API void AiFree_func | ( | void * | addr, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Arnold free()
wrapper.
Releases allocated memory from AiMalloc() and AiRealloc(). Works just like free()
. In practice, you will want to use the associated shortcut macro AiFree().
addr | the address of the memory block to release |
file | filename of the compilation unit calling AiFree_func() |
line | line-number of the compilation unit calling AiFree_func() |
func | function of the compilation unit calling AiFree_func() |