Custom malloc/mmap for x86_64

Paul Pluzhnikov ppluzhnikov@google.com
Sat Apr 28 20:59:00 GMT 2012


On Sat, Apr 28, 2012 at 1:34 PM, Daniel <lbathen@gmail.com> wrote:

> I apologize, this might sound confusing, we want to allow programmers
> the option of using traditional malloc and our malloc. So we will
> be using the same structures, etc., malloc uses. But if a programmer who
> is not aware of the library or does not care about memory types, can
> still use malloc. If he cares about the memory type, then he can use our
> my_malloc. We simplify things for the programmer by enhancing glibc with
> our my_malloc.

The goals outlined above are served *perfectly* well by you providing
an extra library, which implements my_malloc. Therefore it is still
entirely unclear why you want to put my_malloc into glibc.

A programmer who doesn't care, doesn't link your library.

A programmer who does care, links your library and calls my_malloc.

A programmer who does care, and wants to redirect all malloc() calls
to your library, links against your library, and also adds the
following piece of code (or you could put it into a special
lib_redirect_all_malloc_to_my_malloc):

  void *malloc(size_t sz) { return my_malloc(sz); }


Hope this helps,
-- 
Paul Pluzhnikov



More information about the Libc-help mailing list