这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

heap API 参考

API 参考

void *wm_heap_caps_alloc(size_t size, wm_heap_cap_type_t caps)

This function is called by memory allocation.

参数:
  • size[in]

  • caps[in]

返回值:
  • NULL – malloc failed

  • pointer – pointer to the address of the allocated memory

void *wm_heap_caps_realloc(void *old_mem, size_t new_size, wm_heap_cap_type_t caps)

This function is called by memory reallocation.

参数:
  • old_mem[in]

  • new_size[in]

  • caps[in]

返回值:
  • NULL – realloc failed

  • pointer – pointer to the address of the allocated memory

void wm_heap_caps_free(void *p)

This function is used to free memory.

参数:

p[in] memory to be freed

返回:

None

size_t wm_heap_get_free_size(void)

Get free heap size (bytes)

返回:

size_t

size_t wm_heap_get_minimum_ever_free_size(void)

Get minimum ever free heap size (bytes)

返回:

size_t

void wm_heap_print_tracing(void *p)

Show heap memory allocation information.

参数:

p[in] memory pointer that requires an exception hint and can be NULL when normal

返回:

None

void wm_heap_print_stats(void)

Show heap memory statistics.

返回:

None

void wm_heap_init(void)

Initialize heap.

备注

This API must be called before all other heap API can be called, This API will not initialize PSRAM as heap, call wm_heap_append_to_heap to append PSRAM to heap

返回:

None

int wm_heap_append_to_heap(const char *mem_name)

Append the memory to heap.

备注

Use this api append ram to heap, such as PSRAM

返回:

WM_ERR_SUCCESS : OK, WM_ERR_INVALID_PARAM :fail

数据结构参考

enum wm_heap_cap_type_t

Flags to indicate the capabilities of the various memory systems.

Values:

enumerator WM_HEAP_CAP_DEFAULT

Memory can be returned in a non-capability-specific memory allocation (e.g. malloc(), calloc()) call.

enumerator WM_HEAP_CAP_INTERNAL

Memory must be internal; specifically it should not disappear when flash/spiram cache is switched off.

enumerator WM_HEAP_CAP_SPIRAM

Memory must be in SPI RAM.

enumerator WM_HEAP_CAP_EXEC

Memory must be able to run executable code.

enumerator WM_HEAP_CAP_SHARED

Memory must be able to accessed by WiFi & HSPI/SDIO Slave.

enumerator WM_HEAP_CAP_INVALID

Memory can’t be used / list end marker.