MCUXpresso heap handling

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MCUXpresso heap handling

1,188 次查看
matteocivale
Contributor II

Hello everyone, i noted a different mode of handle memory heap region between KDS and MCUxpresso. For example I created two identical project for k64k uC one with KDS and the other with #MCUxpresso leaving the same default heap dimension (eg 0x400 for k64f uC) with booth the ide. At run time when call a dinamic allocation function as malloc and try to allocate a memory area with dimensione greater then heap region, with #KDS the uC run without problem and malloc return a right pointer while with MCUxpresso the function return a null pointer. Can someone explane me what are the difference between the two #heap handling ?

标签 (1)
0 项奖励
1 回复

693 次查看
lpcxpresso_supp
NXP Employee
NXP Employee

I can't talk for KDS behaviour, but if the heap allocator finds that there is insufficient space left in the heap area, then you should get a NULL back from malloc(): http://www.cplusplus.com/reference/cstdlib/malloc/ 

Your code should then take the appropriate action after checking for the NULL being returned.

For details of how to modify the amount of space reserved for the heap, please read the MCUXpresso IDE v10.1.0 User Guide, chapter 14, " Memory Configuration and Linker Scripts" - in particular section 14.9, "More advanced heap/stack placement".

Regards,

MCUXpresso IDE Support

0 项奖励