Hello,
In SDK14.2, select an armgcc project, for example, pin_change_int.
For nRF52840, the heapsize is defined in /components/toolchain/gcc/gcc_startup_nrf52840.S, and the default value is 8192.
In the code, I try to allocate a memory of 8193 bytes with below code:
uint8_t *p = NULL; p = (uint8_t *)malloc(8193); if (p != NULL) { nrf_drv_gpiote_out_set(PIN_OUT); // LED off } else { nrf_drv_gpiote_out_clear(PIN_OUT); // LED on }
A NULL is expected as the reture of malloc function, but actually it never happens no matter how big the malloc parameter is.
In Keil/SES, the program behavior is correct with the same code.
What's wrong with it? Can we make the malloc return a NULL when hitting the boundary of the heap space?
(Yes, I have read this link, but there is not a valid workaround)
Best Regards,
Youqun