operator new() and operator delete()

New Message Reply Date view Thread view Subject view Author view

Javier Abadia Miranda (jabadia++at++sfe.indra.es)
Wed, 21 Jul 1999 10:11:51 +0200


Hello:

I want objects of a class to be allocated from shared
arena. I have overloaded operators new and delete as
follows:

class CTruck
{
   public:
        CTruck();
        ~CTruck();
        void *operator new(size_t);
        void *operator new(size_t, void *arena);
        void operator delete(void *);
   ...
}

void *CTruck::operator new(size_t size)
{
    return pfMalloc( size, pfGetSharedArena());
}

void *CTruck::operator new(size_t size, void *arena)
{
    return pfMalloc( size, arena );
}

void CTruck::operator delete(void *p)
{
    pfFree(p);
}

This seems to work. Is it the _right_ way to allocate
objects from shared arena?

I'm wondering if I should derive this class and others
from pfObject or pfMemory to get this allocation behaviour
automatically.

Thanks

-- 
Javier Abadia Miranda    /            Ingeniero en Informatica
MADRID (SPAIN)          /  Especialista en Informatica Grafica

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Jul 21 1999 - 01:18:52 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.