Forum: ARM programming with GCC/GNU tools Alternative to malloc

Author: suresh (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi all,

Iam porting a c application to arm7tdmi which contains malloc and calloc
functions.I want to know wheter is there any other method to allocate
memory other than using malloc for eg; returning a fixed memory address
using a dummy function instead of caling malloc.


Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
You can create your own version of malloc() and place that code in the
link list before the standard libraries, then your version will simply
override the standard implementation. You would also need to override
free(), even if it were just a dummy function.

I did exactly this for example when I needed to integrate zlib
decompression in a bootloader that could not use the standard library at
all. zlib called malloc exactly once with a predictable size, so I just
dummied a malloc().

All that said, why can you not simply use the standard malloc() function
(you only have to implement __sbrk or sbrk_r to make it work, examples
are provided with the WinARM tools in the syscalls.c file)


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.