完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在调试发布版4.1.0的时候,遇到问题:
调用RT_KERNEL_MALLOC object = (struct rt_object *)RT_KERNEL_MALLOC(information->object_size); if (object == RT_NULL) { /* no memory can be allocated */ return RT_NULL; } 对象为空最后,确定是_MEM_MALLOC(_size)返回为空,source insight发现下面_MEM_MOC定义处的宏图发现所有的宏图都没有打开 #if defined(RT_USING_SMALL_MEM_AS_HEAP) static rt_smem_t system_heap; rt_inline void _smem_info(rt_size_t *total, rt_size_t *used, rt_size_t *max_used) { if (total) *total = system_heap->total; if (used) *used = system_heap->used; if (max_used) *max_used = system_heap->max; } #define _MEM_INIT(_name, _start, _size) system_heap = rt_smem_init(_name, _start, _size) #define _MEM_MALLOC(_size) rt_smem_alloc(system_heap, _size) #define _MEM_REALLOC(_ptr, _newsize) rt_smem_realloc(system_heap, _ptr, _newsize) #define _MEM_FREE(_ptr) rt_smem_free(_ptr) #define _MEM_INFO(_total, _used, _max) _smem_info(_total, _used, _max) #elif defined(RT_USING_MEMHEAP_AS_HEAP) static struct rt_memheap system_heap; void *_memheap_alloc(struct rt_memheap *heap, rt_size_t size); void _memheap_free(void *rmem); void *_memheap_realloc(struct rt_memheap *heap, void *rmem, rt_size_t newsize); #define _MEM_INIT(_name, _start, _size) rt_memheap_init(&system_heap, _name, _start, _size) #define _MEM_MALLOC(_size) _memheap_alloc(&system_heap, _size) #define _MEM_REALLOC(_ptr, _newsize) _memheap_realloc(&system_heap, _ptr, _newsize) #define _MEM_FREE(_ptr) _memheap_free(_ptr) #define _MEM_INFO(_total, _used, _max) rt_memheap_info(&system_heap, _total, _used, _max) #elif defined(RT_USING_SLAB_AS_HEAP) static rt_slab_t system_heap; rt_inline void _slab_info(rt_size_t *total, rt_size_t *used, rt_size_t *max_used) { if (total) *total = system_heap->total; if (used) *used = system_heap->used; if (max_used) *max_used = system_heap->max; } #define _MEM_INIT(_name, _start, _size) system_heap = rt_slab_init(_name, _start, _size) #define _MEM_MALLOC(_size) rt_slab_alloc(system_heap, _size) #define _MEM_REALLOC(_ptr, _newsize) rt_slab_realloc(system_heap, _ptr, _newsize) #define _MEM_FREE(_ptr) rt_slab_free(system_heap, _ptr) #define _MEM_INFO _slab_info #else #define _MEM_INIT(...) #define _MEM_MALLOC(...) RT_NULL #define _MEM_REALLOC(...) RT_NULL #define _MEM_FREE(...) #define _MEM_INFO(...) #endif RT_USING_SMALL_MEM_AS_HEAP RT_USING_MEMHEAP_AS_HEAP RT_USING_SLAB_AS_HEAP 应该是宏最终这样被定义#define _MEM_MALLOC(...) RT_NULL为NULL的原因吧。 |
|
相关推荐
2个回答
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
AI模型部署边缘设备的奇妙之旅:如何在边缘端部署OpenCV
1591 浏览 0 评论
tms320280021 adc采样波形,为什么adc采样频率上来波形就不好了?
1112 浏览 0 评论
1557 浏览 0 评论
1402 浏览 0 评论
1044 浏览 0 评论
74647 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-20 03:09 , Processed in 1.390446 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号