修复了一个malloc的问题

This commit is contained in:
2026-09-18 17:46:46 +08:00
parent 2d0ec356ad
commit abec4bf592
9 changed files with 941 additions and 37 deletions
+27
View File
@@ -32,6 +32,33 @@ typedef struct {
uint32_t mtime;
} cfg_file_stat_t;
/*
* 函数功能:分配共享核心临时缓冲(由平台后端提供:MCU = FreeRTOS 堆 pvPortMalloc,
* 模拟器 = 宿主 CRT malloc)
* 入口参数:size - 字节数 size_t
* 返回值:缓冲指针(内容未清零);失败返回 NULL void *
* 限定条件:必须与 cfg_store_free 配对;共享核心(cfg_file.c / net_cfg.c)禁止直接
* 调用 C 库 malloc——MCU 端 MicroLIB C 堆仅 512 B(startup Heap_Size=0x200),
* KB 级分配必然失败,一律经本接口取 FreeRTOS 堆
*/
void *cfg_store_alloc(size_t size);
/*
* 函数功能:释放 cfg_store_alloc 分配的临时缓冲
* 入口参数:p_buf - 缓冲指针(NULL 安全) void *
* 返回值:无
* 限定条件:p_buf 必须来自 cfg_store_alloc(不得跨分配器释放、不得释放栈地址)
*/
void cfg_store_free(void *p_buf);
/*
* 函数功能:当前空闲堆字节数(分配失败诊断用,非精确预算)
* 入口参数:无
* 返回值:空闲字节数;模拟器不跟踪宿主堆,恒返回 0 uint32_t
* 限定条件:无
*/
uint32_t cfg_store_heap_free(void);
/*
* 函数功能:读文件(最多 cap 字节)
* 入口参数:p_path - 文件路径 const char *