Interesting.

I used an inline form:

inline void * operator new( unsigned long, void* ptr )
{
        return ptr;
}

This worked fine under CW5. Will it not work under CW6? I haven't gotten
around to getting a copy of CW6 yet.

>It appears that the bottom line is this - you can't override a placement new
>operator using CW6.
>
>I read up on it, and tried to implement it a placement form of the new
>operator in CW6.  Codewarrior won't let me!  Apparently the only kind of
>operator new overrides I can do are those defined as such:
>
>#pragma overload       extern void *operator new(size_t) throw(bad_alloc);
>#pragma overload       extern void *operator new(size_t,const nothrow_t&)
>throw();
>#pragma overload       extern void operator delete(void *) throw();
>
>#if __MWERKS__>=0x2020
>#pragma overload       extern void *operator new[](size_t)
>throw(bad_alloc);
>#pragma overload       extern void *operator new[](size_t,const nothrow_t&)
>throw();
>#pragma overload       extern void operator delete[](void *) throw();
>#endif
>
>The MSL C++ reference reiterates this on page 53 of the PDF file, section
>17.4.3.4.
>
>If you attempt to overload the new operator with a 'place' argument, as
>such:
>void* operator new( size_t size, void* place ) { return place; }
>
>I get "illegal 'operator' declaration."
>
>My only alternative at this point is to do it manually.  That is:
>
>{
>static VoidHand hMem = MemHandleNew( sizeof(MyClass));
>
>VoidPtr  pMem = (VoidPtr) MemHandleLock( hMem );
>MyClass myClassInstance(5, true );     // some c'tor args
>MemMove( pMem, &myClassInstance, sizeof(MyClass));
>MemHandleUnlock( hMem ) ; pMem = NULL;
>
>// To use:
>MyClass* pMyClass = (MyClass*) MemHandleLock( hMem );
>pMyClass->someFunction();
>MemHandleUnlock( hMem );
>}
>
>In my testing, it seems you only need to do the MemMove() if your class has
>virtual functions.
>
>-Jeff Ishaq
>Vanteon (formerly The Windward Group)
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe,
>please see http://www.palm.com/devzone/mailinglists.html


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to