overwrite operator new and delete
| Tue, 2005-02-01 21:16 | |
|
Hello,
In our application we wanted to do memory management by ourselves. Basically we will allocate a chunk of memory that is big enough for our use and overwrite operator new and delete, so that inside our application all the memory allocation is done through the big chunk. However we encounter a linker error complaining operator new and deleted is all ready defined. One of the symbian headers (e32std.h) overwrites new and delete. I understand why there is a new with a "TLeave" parameter, but I don't understand why the normal new and delete is overwritten --- can anyone tell me if there is any special work done in this new and delete? In our code we have to include e32std.h for its other functionalities, but then we can not use our own new and delete --- is there a workaround that we can have both? Thanks for your response. |
|






Forum posts: 2009
Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant
Forum posts: 20
GLREF_C TAny* operator new(TUint aSize);
GLREF_C void operator delete(TAny* aPtr);
Do they do anything special? Thanks
ultimatley calls RHeap::AllocL(), via User::AllocL() if I remember
operator new(TUint aSize)
calls
RHeap::Alloc() via User::Alloc().
However those overloads don't exist anymore.
Forum posts: 192
Forum posts: 1379
http://forum.newlc.com/viewtopic.php?t=4083
You can't just provide your own new and delete in the global namespace, because these have already been defined in the base libs and as you notice, you get linker errors.
You either have to use the same tricks new (ELeave) does - so you'd end up doing something like new (EMyMemoryManager) - or you use namespaces to seperate your new and delete from the global namespace.
It's discussed in depth in that thread.
didster
Forum posts: 20