C++ Objects in pfDataPool

New Message Reply Date view Thread view Subject view Author view

Chehayeb, Nassouh (nchehayeb++at++ceit.es)
Tue, 19 Aug 1997 19:36:55 +0200


Hi Performers,

        I want to create a general method to allocate object form a
pfDataPool, so I create the following class:

/*___________________________________________________*/
//PoolObject.h
        extern pfDataPool *GetDataPool();

        class PoolObject
        {
        public:
           void *operator new(size_t sz, int id = 0);
               void operator delete(void *mem);
        };
         
//PoolObject.cxx

        void *PoolObject::operator new(size_t sz, int id)
        {
        void *mem;

          mem = (void *) GetDataPool()->alloc(sz, id); // żżż cast from
volatile void * to void * ???
         if (mem == NULL)
           pfNotify(/* error code */);

        return (mem);
        }

/*_________________________________________________*/

the user now can create its own classes that derive from my class and
use the operator new to create objects in the following way:

/*_________________________________________________*/

// MyObject.h

        class MyObject: public PoolObject
        {
         protected:
           int val;
         
        public:
           MyObject(int _val) { val = _val;}
         ~MyObject() {}
        };

// in othe file the used can write:
        MyObject *mo = new MyObject(500);
// will create the object in the pool memory and call its constuctor.
/*__________________________________________________*/

The problem is that this method may causes a SIGBUS error (because of
the cast above?).

Any help will be appreciated.

Nassouh Adel Chehayeb
C.E.I.T.
(Centro de Estudios e Investigaciones Tecnicas de Guipuzkoa)
Applied Mechanics Department
Paseo de Manuel Lardizabal - 15
20009. San Sebastian (SPAIN)
e-mail: nchehayeb++at++ceit.es
Phone: ++34-43-21.28.00
Fax : ++34-43-21.30.76

===================================List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:45 PDT

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