WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
Dynamic memory
Dynamic memory 的协作图:

结构体

struct  LOS_MEM_POOL_STATUS
 

宏定义

#define OS_SYS_MEM_ADDR   (&__heap_start)
 
#define OS_SYS_MEM_SIZE
 
#define MEM_MODULE_MAX   0x20
 
#define LOS_MEM_INIT_ATTR_SLAB_POS   0U
 
#define LOS_MEM_CHECK_LEVEL_LOW   0
 
#define LOS_MEM_CHECK_LEVEL_HIGH   1
 
#define LOS_MEM_CHECK_LEVEL_DISABLE   0xff
 
#define LOS_MEM_CHECK_LEVEL_DEFAULT   LOS_MEM_CHECK_LEVEL_DISABLE
 
#define LOS_ERRNO_MEMCHECK_PARA_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1)
 
#define LOS_ERRNO_MEMCHECK_OUTSIDE   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2)
 
#define LOS_ERRNO_MEMCHECK_NO_HEAD   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3)
 
#define LOS_ERRNO_MEMCHECK_WRONG_LEVEL   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4)
 
#define LOS_ERRNO_MEMCHECK_DISABLED   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5)
 

类型定义

typedef void(* MALLOC_HOOK) (void)
 Define the type of the customized tuning function when calling the API LOS_MemAlloc to allocate memory.
 

函数

void * LOS_MemMalloc (void *pool, UINT32 size, UINT32 moduleId)
 Allocate dynamic memory.
 
void * LOS_MemMallocAlign (void *pool, UINT32 size, UINT32 boundary, UINT32 moduleId)
 Allocate aligned memory.
 
UINT32 LOS_MemMfree (void *pool, void *ptr, UINT32 moduleId)
 Free dynamic memory.
 
void * LOS_MemMrealloc (void *pool, void *ptr, UINT32 size, UINT32 moduleId)
 Re-allocate a memory block.
 
UINT32 LOS_MemMusedGet (UINT32 moduleId)
 get the used memory size of the specified module.
 
UINT32 LOS_MemDeInit (void *pool)
 Deinitialize dynamic memory.
 
UINT32 LOS_MemPoolList (void)
 Print information about all pools.
 
UINT32 LOS_MemPoolInit (void *pool, UINT32 size, UINT32 attr)
 Initialize dynamic memory.
 
UINT32 LOS_MemInit (void *pool, UINT32 size)
 Initialize dynamic memory.
 
void * LOS_MemAlloc (void *pool, UINT32 size)
 Allocate dynamic memory.
 
UINT32 LOS_MemFree (void *pool, void *ptr)
 Free dynamic memory.
 
void * LOS_MemRealloc (void *pool, void *ptr, UINT32 size)
 Re-allocate a memory block.
 
void * LOS_MemAllocAlign (void *pool, UINT32 size, UINT32 boundary)
 Allocate aligned memory.
 
UINT32 LOS_MemPoolSizeGet (const void *pool)
 Get the size of memory pool's size.
 
UINT32 LOS_MemTotalUsedGet (void *pool)
 Get the size of memory totally used.
 
UINT32 LOS_MemFreeBlksGet (void *pool)
 Get the number of free memory nodes.
 
UINT32 LOS_MemUsedBlksGet (void *pool)
 Get the number of used memory nodes.
 
UINT32 LOS_MemTaskIdGet (const void *ptr)
 Get the task ID of a used memory node.
 
UINTPTR LOS_MemLastUsedGet (void *pool)
 Get the address of the next byte of the last used byte.
 
UINT32 LOS_MemInfoGet (void *pool, LOS_MEM_POOL_STATUS *poolStatus)
 Get the information of memory pool.
 
UINT32 LOS_MemFreeNodeShow (void *pool)
 Get the number of free node in every size.
 
UINT32 LOS_MemIntegrityCheck (const void *pool)
 Check the memory pool integrity.
 

变量

MALLOC_HOOK g_MALLOC_HOOK
 
UINT8m_aucSysMem0
 
UINT8m_aucSysMem1
 

详细描述

宏定义说明

◆ LOS_ERRNO_MEMCHECK_DISABLED

#define LOS_ERRNO_MEMCHECK_DISABLED   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x5)

memcheck error code: memcheck function is not enable.

Value: 0x02000105.

Solution: enable memcheck by the function "LOS_MemCheckLevelSet".

◆ LOS_ERRNO_MEMCHECK_NO_HEAD

#define LOS_ERRNO_MEMCHECK_NO_HEAD   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x3)

memcheck error code: can't find the control node.

Value: 0x02000103.

Solution: check if the node which the pointer points to has been freed or not been allocated.

◆ LOS_ERRNO_MEMCHECK_OUTSIDE

#define LOS_ERRNO_MEMCHECK_OUTSIDE   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x2)

memcheck error code: the pointer address is not in the suitable range.

Value: 0x02000102.

Solution: check pointer and comfirm it is in stack.

◆ LOS_ERRNO_MEMCHECK_PARA_NULL

#define LOS_ERRNO_MEMCHECK_PARA_NULL   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x1)

memcheck error code: the pointer or pool is NULL.

Value: 0x02000101.

Solution: don't give a NULL parameter.

◆ LOS_ERRNO_MEMCHECK_WRONG_LEVEL

#define LOS_ERRNO_MEMCHECK_WRONG_LEVEL   LOS_ERRNO_OS_ERROR(LOS_MOD_MEM, 0x4)

memcheck error code: the memcheck level is wrong.

Value: 0x02000104.

Solution: check the memcheck level by the function "LOS_MemCheckLevelGet".

◆ LOS_MEM_CHECK_LEVEL_DEFAULT

#define LOS_MEM_CHECK_LEVEL_DEFAULT   LOS_MEM_CHECK_LEVEL_DISABLE

Define a mem size check intensity.

default intensity set mem check.

◆ LOS_MEM_CHECK_LEVEL_DISABLE

#define LOS_MEM_CHECK_LEVEL_DISABLE   0xff

Define a mem size check intensity

disable mem check.

◆ LOS_MEM_CHECK_LEVEL_HIGH

#define LOS_MEM_CHECK_LEVEL_HIGH   1

Define a mem size check intensity

Highest mem check.

◆ LOS_MEM_CHECK_LEVEL_LOW

#define LOS_MEM_CHECK_LEVEL_LOW   0

Define a mem size check intensity

Lowest mem check.

◆ LOS_MEM_INIT_ATTR_SLAB_POS

#define LOS_MEM_INIT_ATTR_SLAB_POS   0U

The attributes to config memory pool. Bit 0 is used to config the memory pool containing slab. The other 31 bits are reserved now.

◆ MEM_MODULE_MAX

#define MEM_MODULE_MAX   0x20

The memory usage statistics depend on module, this is the max module number 0x20. Note that this macro is defined only when LOSCFG_MEM_MUL_MODULE is defined.

◆ OS_SYS_MEM_ADDR

#define OS_SYS_MEM_ADDR   (&__heap_start)

Starting address of the system memory

◆ OS_SYS_MEM_SIZE

#define OS_SYS_MEM_SIZE
值:
((LOS_DL_HEAP_SIZE + ((UINTPTR)&__heap_start) + (64 - 1)) & ~(64 - 1)))
UINTPTR g_sys_mem_addr_end
#define LOS_DL_HEAP_SIZE
Definition los_config.h:237
LD_SYMBOL_TYPE __heap_start
unsigned int UINTPTR
Definition los_typedef.h:74

Memory size

类型定义说明

◆ MALLOC_HOOK

typedef void(* MALLOC_HOOK) (void)

Define the type of the customized tuning function when calling the API LOS_MemAlloc to allocate memory.

Description:
This definition is used to declare the customized tuning function when calling the API LOS_MemAlloc to allocate memory.
注意
None.
参数
None.
返回值
None.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

函数说明

◆ LOS_MemAlloc()

void * LOS_MemAlloc ( void *  pool,
UINT32  size 
)
extern

Allocate dynamic memory.

Description:
This API is used to allocate a memory block of which the size is specified.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The size of the input parameter size can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The size of the input parameter size must be four byte-aligned.
参数
pool[IN] Pointer to the memory pool that contains the memory block to be allocated.
size[IN] Size of the memory block to be allocated (unit: byte).
返回值
NULLThe memory fails to be allocated.
#VOID*The memory is successfully allocated, and the API returns the pointer to the allocated memory block.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemRealloc | LOS_MemAllocAlign | LOS_MemFree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemAllocAlign()

void * LOS_MemAllocAlign ( void *  pool,
UINT32  size,
UINT32  boundary 
)
extern

Allocate aligned memory.

Description:
This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on a specified boundary.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The size of the input parameter size can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The alignment parameter value must be a power of 2 with the minimum value being 4.
参数
pool[IN] Pointer to the memory pool that contains the memory blocks to be allocated.
size[IN] Size of the memory to be allocated.
boundary[IN] Boundary on which the memory is aligned.
返回值
NULLThe memory fails to be allocated.
#VOID*The memory is successfully allocated, and the API returns the pointer to the allocated memory.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemAlloc | LOS_MemRealloc | LOS_MemFree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemDeInit()

UINT32 LOS_MemDeInit ( void *  pool)
extern

Deinitialize dynamic memory.

Description:
This API is used to deinitialize the dynamic memory of a doubly linked list.
注意
This function is defined only when LOSCFG_MEM_MUL_POOL is defined.
参数
pool[IN] Starting address of memory.
返回值
LOS_NOKThe dynamic memory fails to be deinitialized.
LOS_OKThe dynamic memory is successfully deinitialized.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemFree()

UINT32 LOS_MemFree ( void *  pool,
void *  ptr 
)
extern

Free dynamic memory.

Description:
This API is used to free specified dynamic memory that has been allocated.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign or LOS_MemRealloc.
参数
pool[IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
ptr[IN] Starting address of the memory block to be freed.
返回值
LOS_NOKThe memory block fails to be freed because the starting address of the memory block is invalid, or the memory overwriting occurs.
LOS_OKThe memory block is successfully freed.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemAlloc | LOS_MemRealloc | LOS_MemAllocAlign
自从
Huawei LiteOS V100R001C00

◆ LOS_MemFreeBlksGet()

UINT32 LOS_MemFreeBlksGet ( void *  pool)
extern

Get the number of free memory nodes.

Description:
This API is used to get the number of free memory nodes in memory pool.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
返回值
LOS_NOKThe input parameter pool is NULL.
UINT32The number of free memory nodes.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemFreeNodeShow()

UINT32 LOS_MemFreeNodeShow ( void *  pool)
extern

Get the number of free node in every size.

Description:
This API is used to print the number of free node in every size.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
返回值
LOS_NOKThe input parameter pool is NULL.
LOS_OKPrint the number of free node in every size successfully.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemInfoGet()

UINT32 LOS_MemInfoGet ( void *  pool,
LOS_MEM_POOL_STATUS poolStatus 
)
extern

Get the information of memory pool.

Description:
This API is used to get the information of memory pool.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
poolStatus[OUT] A pointer for storage the pool status
返回值
LOS_NOKThe input parameter pool is NULL or invalid.
LOS_OKGet memory information successfully.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemInit()

UINT32 LOS_MemInit ( void *  pool,
UINT32  size 
)
extern

Initialize dynamic memory.

Description:
This API is used to initialize the dynamic memory of a doubly linked list.
注意
  • The size parameter value should match the following two conditions : 1) Be less than or equal to the Memory pool size; 2) Be greater than the size of OS_MEM_MIN_POOL_SIZE.
  • Call this API when dynamic memory needs to be initialized during the startup of Huawei LiteOS.
  • The parameter input must be OS_MEM_ALIGN_SIZE byte-aligned.
  • The init area [pool, pool + size] should not conflict with other pools.
参数
pool[IN] Starting address of memory.
size[IN] Memory size.
返回值
LOS_NOKThe dynamic memory fails to be initialized.
LOS_OKThe dynamic memory is successfully initialized.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemIntegrityCheck()

UINT32 LOS_MemIntegrityCheck ( const void *  pool)
extern

Check the memory pool integrity.

Description:
This API is used to check the memory pool integrity.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • LOS_MemIntegrityCheck will be called by malloc function when the macro of LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK is defined in LiteOS.
  • LOS_MemIntegrityCheck function can be called by user anytime.
参数
pool[IN] A pointer to the memory pool.
返回值
LOS_NOKThe memory pool (pool) is impaired.
LOS_OKThe memory pool (pool) is integrated.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemLastUsedGet()

UINTPTR LOS_MemLastUsedGet ( void *  pool)
extern

Get the address of the next byte of the last used byte.

Description:
This API is used to get the address of the next byte of the last used byte.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The last used byte may the last byte of an used node or the last byte of an unused node head
参数
pool[IN] A pointer pointed to the memory pool.
返回值
LOS_NOKThe input parameter pool is NULL.
UINTPTRThe pointer to the next byte of the last used byte.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemMalloc()

void * LOS_MemMalloc ( void *  pool,
UINT32  size,
UINT32  moduleId 
)
extern

Allocate dynamic memory.

Description:
This API is used to allocate a memory block of which the size is specified and update module mem used.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The size of the input parameter size can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The size of the input parameter size must be four byte-aligned.
  • This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
参数
pool[IN] Pointer to the memory pool that contains the memory block to be allocated.
size[IN] Size of the memory block to be allocated (unit: byte).
moduleId[IN] module ID (0~MODULE_MAX).
返回值
NULLThe memory fails to be allocated.
#VOID*The memory is successfully allocated, and the API returns the pointer to the allocated memory block.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemMrealloc | LOS_MemMallocAlign | LOS_MemMfree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemMallocAlign()

void * LOS_MemMallocAlign ( void *  pool,
UINT32  size,
UINT32  boundary,
UINT32  moduleId 
)
extern

Allocate aligned memory.

Description:
This API is used to allocate memory blocks of specified size and of which the starting addresses are aligned on a specified boundary and update module mem used.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The size of the input parameter size can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The alignment parameter value must be a power of 2 with the minimum value being 4.
  • This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
参数
pool[IN] Pointer to the memory pool that contains the memory blocks to be allocated.
size[IN] Size of the memory to be allocated.
boundary[IN] Boundary on which the memory is aligned.
moduleId[IN] module ID (0~MODULE_MAX).
返回值
NULLThe memory fails to be allocated.
#VOID*The memory is successfully allocated, and the API returns the pointer to the allocated memory.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemMalloc | LOS_MemRealloc | LOS_MemMfree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemMfree()

UINT32 LOS_MemMfree ( void *  pool,
void *  ptr,
UINT32  moduleId 
)
extern

Free dynamic memory.

Description:
This API is used to free specified dynamic memory that has been allocated and update module mem used.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The input ptr parameter must be allocated by LOS_MemMalloc or LOS_MemMallocAlign or LOS_MemMrealloc.
  • This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
参数
pool[IN] Pointer to the memory pool that contains the dynamic memory block to be freed.
ptr[IN] Starting address of the memory block to be freed.
moduleId[IN] module ID (0~MODULE_MAX).
返回值
LOS_NOKThe memory block fails to be freed because the starting address of the memory block is invalid, or the memory overwriting occurs.
LOS_OKThe memory block is freed successfully.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemMalloc | LOS_MemMrealloc | LOS_MemMallocAlign
自从
Huawei LiteOS V100R001C00

◆ LOS_MemMrealloc()

void * LOS_MemMrealloc ( void *  pool,
void *  ptr,
UINT32  size,
UINT32  moduleId 
)
extern

Re-allocate a memory block.

Description:
This API is used to allocate a new memory block of which the size is specified by size if the original memory block size is insufficient. The new memory block will copy the data in the original memory block of which the address is specified by ptr.The size of the new memory block determines the maximum size of data to be copied. After the new memory block is created, the original one is freed. And update module mem used.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The input ptr parameter must be allocated by LOS_MemMalloc or LOS_MemMallocAlign.
  • The size of the input parameter size can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The size of the input parameter size must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc, it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemMallocAlign, it must be aligned with the size of the input parameter boundary of LOS_MemMallocAlign.
  • This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
参数
pool[IN] Pointer to the memory pool that contains the original and new memory blocks.
ptr[IN] Address of the original memory block.
size[IN] Size of the new memory block.
moduleId[IN] module ID (0~MODULE_MAX).
返回值
NULLThe memory fails to be re-allocated.
#VOID*The memory is successfully re-allocated, and the API returns the pointer to the new memory block.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemMalloc | LOS_MemMallocAlign | LOS_MemMfree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemMusedGet()

UINT32 LOS_MemMusedGet ( UINT32  moduleId)
extern

get the used memory size of the specified module.

Description:
This API is used to get the specified module's memory consume size.
注意
This function is defined only when LOSCFG_MEM_MUL_MODULE is defined.
参数
moduleId[IN] module ID (0~MODULE_MAX).
返回值
UINT32The size of the specified module's consumed memory.
OS_NULL_INTThe input module id is illegal.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemPoolInit()

UINT32 LOS_MemPoolInit ( void *  pool,
UINT32  size,
UINT32  attr 
)
extern

Initialize dynamic memory.

Description:
This API is used to initialize the dynamic memory of a doubly linked list.
注意
  • The size parameter value should match the following two conditions : 1) Be less than or equal to the Memory pool size; 2) Be greater than the size of OS_MEM_MIN_POOL_SIZE.
  • Call this API when dynamic memory needs to be initialized during the startup of Huawei LiteOS.
  • The parameter input must be OS_MEM_ALIGN_SIZE byte-aligned.
  • The init area [pool, pool + size] should not conflict with other pools.
参数
pool[IN] Starting address of memory.
size[IN] Memory size.
attr[IN] Attributes to config memory pool, see LOS_MEM_INIT_ATTR_SLAB_MSK above.
返回值
LOS_NOKThe dynamic memory fails to be initialized.
LOS_OKThe dynamic memory is successfully initialized.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V200R006C10

◆ LOS_MemPoolList()

UINT32 LOS_MemPoolList ( void  )
extern

Print information about all pools.

Description:
This API is used to print information about all pools.
注意
This function is defined only when LOSCFG_MEM_MUL_POOL is defined.
参数
None.
返回值
UINT32The pool number.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemPoolSizeGet()

UINT32 LOS_MemPoolSizeGet ( const void *  pool)
extern

Get the size of memory pool's size.

Description:
This API is used to get the size of memory pool' total size.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
返回值
LOS_NOKThe input parameter pool is NULL.
UINT32The size of the memory pool.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemRealloc()

void * LOS_MemRealloc ( void *  pool,
void *  ptr,
UINT32  size 
)
extern

Re-allocate a memory block.

Description:
This API is used to allocate a new memory block of which the size is specified by size if the original memory block size is insufficient. The new memory block will copy the data in the original memory block of which the address is specified by ptr. The size of the new memory block determines the maximum size of data to be copied. After the new memory block is created, the original one is freed.
注意
  • The input pool parameter must be initialized via func LOS_MemInit.
  • The input ptr parameter must be allocated by LOS_MemAlloc; if the ptr is allocated by LOS_MemAllocAlign, the alignment of the newly allocated memory address cannot be guaranteed to be consistent with the original memory address.
  • The input size parameter can not be greater than the memory pool size that specified at the second input parameter of LOS_MemInit.
  • The input size parameter must be aligned as follows: 1) if the ptr is allocated by LOS_MemAlloc, it must be four byte-aligned; 2) if the ptr is allocated by LOS_MemAllocAlign, it must be aligned with the size of the input parameter boundary of LOS_MemAllocAlign.
  • If the user has special requirements for address alignment, it is not recommended to use this realloc function for address allocated by LOS_MemAllocAlign. For example, on a 32-bit system, LiteOS's default address alignment is 4 bytes, and if the boundary specified in LOS_MemAllocAlign is 8 bytes, it is cannot be ensured that the reallocated address is 8 bytes aligned.
参数
pool[IN] Pointer to the memory pool that contains the original and new memory blocks.
ptr[IN] Address of the original memory block.
size[IN] Size of the new memory block.
返回值
NULLThe memory fails to be re-allocated.
#VOID*The memory is successfully re-allocated, and the API returns the pointer to the new memory block.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
参见
LOS_MemAlloc | LOS_MemAllocAlign | LOS_MemFree
自从
Huawei LiteOS V100R001C00

◆ LOS_MemTaskIdGet()

UINT32 LOS_MemTaskIdGet ( const void *  ptr)
extern

Get the task ID of a used memory node.

Description:
This API is used to get the task ID of a used memory node.
注意
  • The input ptr parameter must be allocated by LOS_MemAlloc or LOS_MemAllocAlign.
  • This interface only support obtain the task ID of a used memory node which is allocated from the system memory pool (OS_SYS_MEM_ADDR) at present.
  • This API can be enabled when you set the macro value of LOSCFG_MEM_DEBUG or LOSCFG_MEM_TASK_STAT is defined in LiteOS.
参数
ptr[IN] A used memory node.
返回值
OS_INVALIDThe input parameter ptr is illegal.
UINT32The task ID of used memory node ptr.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemTotalUsedGet()

UINT32 LOS_MemTotalUsedGet ( void *  pool)
extern

Get the size of memory totally used.

Description:
This API is used to get the size of memory totally used in memory pool.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
返回值
LOS_NOKThe input parameter pool is NULL.
UINT32The size of the used memory pool.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

◆ LOS_MemUsedBlksGet()

UINT32 LOS_MemUsedBlksGet ( void *  pool)
extern

Get the number of used memory nodes.

Description:
This API is used to get the number of used memory nodes in memory pool.
注意
The input pool parameter must be initialized via func LOS_MemInit.
参数
pool[IN] A pointer pointed to the memory pool.
返回值
OS_INVALIDThe input parameter pool is NULL.
UINT32The number of used memory nodes.
Dependency:
  • los_memory.h: the header file that contains the API declaration.
自从
Huawei LiteOS V100R001C00

变量说明

◆ g_MALLOC_HOOK

MALLOC_HOOK g_MALLOC_HOOK
extern

Customized tuning function when calling the API LOS_MemAlloc to allocate memory.

◆ m_aucSysMem0

UINT8* m_aucSysMem0
extern

The start address of exception interaction dynamic memory pool address, when the exception interaction feature not support, m_aucSysMem0 equals to m_aucSysMem1.

◆ m_aucSysMem1

UINT8* m_aucSysMem1
extern

The start address of system dynamic memory pool address.