XFusion API v1.3.0
载入中...
搜索中...
未找到
examples/system/heap/main/xf_main.c

动态内存示例。

1
17/* ==================== [Includes] ========================================== */
18
19#include "xf_utils.h"
20
21/* ==================== [Defines] =========================================== */
22
23#define TAG "example_heap"
24
25/* ==================== [Typedefs] ========================================== */
26
27/* ==================== [Static Prototypes] ================================= */
28
29/* ==================== [Static Variables] ================================== */
30
31/* ==================== [Macros] ============================================ */
32
33/* ==================== [Global Functions] ================================== */
34
35void xf_main(void)
36{
37 size_t size = xf_heap_get_free_size();
38 XF_LOGI(TAG, "free size:%d", size);
39
40 int *value = (int *)xf_malloc(sizeof(int));
41 *value = 11;
42 XF_LOGI(TAG, "value:%d", *value);
43
44 size = xf_heap_get_free_size();
45 XF_LOGI(TAG, "free size:%d", size);
46
47 xf_free(value);
48
49 size = xf_heap_get_free_size();
50 XF_LOGI(TAG, "free size:%d", size);
51}
52
53/* ==================== [Static Functions] ================================== */
void xf_main(void)
Definition xf_main.c:28
unsigned int xf_heap_get_free_size(void)
获取内存总空闲大小。
Definition xf_heap.c:125
#define xf_malloc(x)
Definition xf_stdlib.h:38
#define xf_free(x)
Definition xf_stdlib.h:39
#define TAG
Definition xf_main.c:24
#define XF_LOGI(tag, format,...)