0
\$\begingroup\$

Does using memory allocation API such calloc / malloc cause issues on ARM based boards ? I recently faced a issue wherein I used calloc (1024 Bytes) and this buffer was used across many functions in a single source file. I observed the output of a particular function varied randomly when calloc was used, but when I switched over to a fixed array, the issue never showed up. Hence I am wondering if calloc has got any limitations on a small memory footprint board.

\$\endgroup\$
2
\$\begingroup\$

Assuming you get no error return from the calloc/malloc, the odds are about 9999 to one on that you have a bug, either due to misuse of malloc, misuse of the space so allocated, incorrect memory sections/placement or just because the fixed and malloced buffers will have different addresses.

\$\endgroup\$
1
\$\begingroup\$

This depends on your C library, which in turn depends on your compiler and chosen ARM device.

If you are using embedded Linux on ARM with glibc/uclibc then you should have no problems with malloc.

If you're programming "on the metal" with a limited libc, you should check the documentation to see how well supported malloc is. You may need to configure the heap in your C startup code.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.