delete ? new ??

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
gtsphere

delete ? new ??

Post by gtsphere »

well i ran into something i thought i could have gotten around, the new and delete operators... lol

well i need a delete operator, any ideas? i really haven't seen many around to even learn from

thanks in advance soo much!
grey wolf

Re:delete ? new ??

Post by grey wolf »

Code: Select all

void operator delete (void* p) { free(p); }
you might need the array variant, but i don't recall the exact code at the moment. of course, replace free() with your kernel's free() function.
Tim

Re:delete ? new ??

Post by Tim »

Code: Select all

operator new(size_t size)
{
    return malloc(size);
}

operator new[](size_t size)
{
    return malloc(size);
}

operator delete(void *p)
{
    free(p);
}

operator delete[](void *p)
{
    free(p);
}
Schol-R-LEA

Re:delete ? new ??

Post by Schol-R-LEA »

No offense, Tim, but that answer only helps if Gtsphere has already written a memory mangler and implemented malloc() and free() based on it.

Then again, GTS seems to be OK with this answer (or at least hasn't complained about it), so perhaps he has.

It's issues like this that make me want to use a garbage-collecting system for the code outside of the kernel proper. ;)
Post Reply