Memory

Last Updated on : 2021-07-17 10:21:50download

API list

Function name Description
*Malloc Request memory allocation.
Free Free memory.

API description

*Malloc

Function prototype

VOID *Malloc(IN SIZE_T reqSize);

Parameters

Parameter name Parameter type Description
reqSize IN SIZE_T The size of the requested memory allocation.

Return value

Return value Description
NULL Memory allocation failed.
Other The first address of the allocated memory space.

Free

Function prototype

VOID Free(IN PVOID_T pReqMem);

Parameters

Parameter name Parameter type Description
pReqMem PVOID_T The first address of the memory space to be freed.

Example

// After the system initialization is completed, call this interface to test memory allocation.
VOID test_memory()
{
	CHAR_T* p = (CHAR_T*)Malloc(100);
	if (!p) {
		PR_ERR("null point");
		return;
	}

	Free(p);
	p = NULL;
}