AngelScript
 
Loading...
Searching...
No Matches
Memory functions

Functions

AS_API int asSetGlobalMemoryFunctions (asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc)
 Set the memory management functions that AngelScript should use.
 
AS_API int asResetGlobalMemoryFunctions ()
 Remove previously registered memory management functions.
 
AS_API void * asAllocMem (size_t size)
 Allocate memory using the memory function registered with AngelScript.
 
AS_API void asFreeMem (void *mem)
 Deallocates memory using the memory function registered with AngelScript.
 

Detailed Description

Function Documentation

◆ asAllocMem()

AS_API void * asAllocMem ( size_t  size)
Parameters
[in]sizeThe size of the buffer to allocate
Returns
A pointer to the allocated buffer, or null on error.

◆ asFreeMem()

AS_API void asFreeMem ( void *  mem)
Parameters
[in]memA pointer to the buffer to deallocate

◆ asResetGlobalMemoryFunctions()

AS_API int asResetGlobalMemoryFunctions ( )
Returns
A negative value on error.

Call this method to restore the default memory management functions.

◆ asSetGlobalMemoryFunctions()

AS_API int asSetGlobalMemoryFunctions ( asALLOCFUNC_t  allocFunc,
asFREEFUNC_t  freeFunc 
)
Parameters
[in]allocFuncThe function that will be used to allocate memory.
[in]freeFuncThe function that will be used to free the memory.
Returns
A negative value on error.

Call this method to register the global memory allocation and deallocation functions that AngelScript should use for memory management. This function should be called before asCreateScriptEngine.

If not called, AngelScript will use the malloc and free functions from the standard C library.