I'm working on a custom memory allocator but the operator delete, redefined in a base class, is not called only on Symbian. Instead the global delete operator is called. This code is 100% pure C++ and I don't know way I receive the warning: "cannot find matching deallocation function for 'A'". I'm using the S60 3rd Edition MR SDK. What can I do to solve this issue?
I also made a DLL that exports the operators. Again I received at the compile time the same warning "cannot find matching deallocation function for 'A'". When I try to run an application that uses the DLL, the emulator gives an error "epoc.exe has triggered a breakpoint" and then it exits.Code:#ifndef __SYMBIAN32__ #include <stdlib.h> #endif class A { public: virtual ~A() {} // A has descendents #ifdef __SYMBIAN32__ void* operator new ( unsigned n, char* /*fileName*/, int /*line*/) { return User::Alloc( n); } void operator delete( void* p) { User::Free( p); } // tried also: void operator delete( void* p, unsigned /*s*/) { User::Free( p); } #else void* operator new ( unsigned n, char* /*fileName*/, int /*line*/) { return malloc( n); } void operator delete( void* p) { free( p); } // tried also: void operator delete( void* p, unsigned /*s*/) { free( p); } #endif }; void test() { A* p = new (__FILE__, __LINE__) A(); delete p; }; int main() { test(); return 0; }
Code:1 ??2A@@SAPAXIPADH@Z (public: static void * __cdecl A::operator new(unsigned int,char *,int)) 2 ??3A@@SAXPAX@Z (public: static void __cdecl A::operator delete(void *)) 3 ??3A@@SAXPAXI@Z (public: static void __cdecl A::operator delete(void *,unsigned int))

Reply With Quote

