gcc new - delete functions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
DruG5t0r3

gcc new - delete functions

Post by DruG5t0r3 »

How do you define the new and delete functions so that they point to your own asm code for example?

Thanks
TheUbu

RE:gcc new - delete functions

Post by TheUbu »

DruG5t0tr3,

With gcc use  the flag -nobuiltin then link against your own libcpp library and define the functions here is some code example:

void * operator new[](unsigned size)
{
    return malloc(size);
}

void operator delete[](void * ptr)
{
    free(ptr);

    return;
}

void * operator new(unsigned size)
{
    return malloc(size);
}

void operator delete(void * ptr)
{
    free(ptr);

    return;
}


Hope that helps if you need further information just let me know.


-Christopher
DruG5t0r3

RE:gcc new - delete functions

Post by DruG5t0r3 »

Wow thank you, exactly what i needed
TheUbu

RE:gcc new - delete functions

Post by TheUbu »

No problem....




-Christopher
Post Reply