Question
stm32f405 malloc issue
Posted on March 31, 2014 at 01:11
Dear,
as in several examples, i implemented my _sbrk function to be able to use malloc, as (copied from examples): extern int _end; /* * _sbrk needed for malloc */ caddr_t _sbrk ( int incr ) { static unsigned char *heap = NULL; unsigned char *prev_heap; if (heap == NULL) { heap = (unsigned char *)&_end; } prev_heap = heap; /* check removed to show basic approach */ heap += incr; return (caddr_t) prev_heap; } Program compiles fine, no warnings, if i call directly _sbrk to allocate memory (instead of malloc) it works perfect, if i instead call ''malloc'', i see that _sbrk is called, but the return value of malloc is an null pointer (0). Probably, malloc after calling sbrk do some other checks, and returns 0. Every help is appreciated. Thanks #worst-forum-software-ever