tags:

views:

69

answers:

2

Hi,

This post is edited and the original post here is asking the implementation of _malloc_r which is not a good move to use.

My question now is there any other malloc implementation or alternative function for malloc and free functions?

Please advice.

Many thanks.

+2  A: 

Give up on trying to have a reentrant malloc. It's a bad idea. If you really need to allocate memory from signal handlers, use mmap, but even that is a bad design.

R..
Just one, is there any other implementation of malloc? or alternative function for malloc and free functions?
sasayins
Replacing `malloc` (or any other part of the C library) results in *undefined behavior*. On any given implementation (e.g. Linux/glibc) there's probably a way to do it, but ensuring that the replacement is not buggy and that it does not break other parts of the standard library or other libraries you might want to use is highly nontrivial, and of course even if you know it works now, that's no assurance that things won't break in future versions.
R..
+2  A: 

There are a lot of alternate malloc implementations, usually intended for debugging or other special purposes. One that you might want to take a look at is Google's tcmalloc.

Paul R