This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to tell compiler to use my_malloc inplace of normal 'malloc'


Just define your malloc function as "malloc", with the exact same C
signature.  Your .o will preferential link in lieu of the libc.so malloc or
lib.a malloc.

extern "C" void* malloc(size_t size);

// My malloc.
void* malloc(size_t size)
{
    // ...my own heap management routines using sbrk and such...
}

--Eljay


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]