I'm trying to use the malloc an calloc functions.
I've included the following headers compiling without any error
#include
#include
#include
but during the execution the malloc always returns NULL.
I have then included the
This is strange, because the definition should already be in the stdlib.h.
I tryied in this the structure
mallinfo
that tells me there is no memory available.
Do I have to include precisely all the haders (for example malloc.h, alloc.h, errno.h) without the stdlib.h header
and from a particular path?
Do I have to tell someting more in the ld script.
Do you have any example that can explain the dynamic memory usage?
Thank you.
M T
Hilscher Gesellschaft für Systemautomation mbH
I assume you are not using any operating system on your target at all.
The standard malloc implementation comes from the newlib included with your Hitex compiler toolchain. To make malloc work you will to implement the system calls which are described in the newlib documentation available at http://sourceware.org/newlib/libc.html.
The functions you need are:
- sbrk_r
- __malloc_lock / __malloc_unlock (for multitasking environment)
Regards
MT