Alternative to malloc

Guest #1172075
Rate this post
• ▲ 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.

Regards
Suresh
#1172076
Rate this post
• ▲ 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)

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.