more more details

New Message Reply Date view Thread view Subject view Author view

David Chan (dchan++at++zeus.lnk.com)
Wed, 29 Apr 1998 12:02:08 -0400 (EDT)


HI,
        I am sorry to mislead the problem about pfMalloc and object
container to assigning object to object container. Since I have try to do
like this, actually I can assign object into object container, but the
problem is I can't access the data filed of this object. Here is the whole
story:
===================================================

class Console: public pfObject {
         
protected: int dummy;
         
public:
        int getDummy() { dummy = 2; return dummy; }
        int getOne() { return 1; }
        virtual void interaction()=0;
}

class Dervied_from_Console : public Console
{
        ...
public: virtual void interaction() { ... }
        ...
}

typedef structure {
        ...
        Console *console[10];
        ...
} SharedData;

SharedData *shared = pfMalloc(sizeof(SharedData),pfGetSharedArena());

shared->console[0] = new Dervied_from_Console();

printf("first try: %d\n",shared->console[0]->getOne()); // this statement is ok

printf("second try: %d\n",shared->console[0]->getDummy()); //Segnmentation fault

======================================================

I do the allocation of shared memory before pfConfig(), and I have try to
use malloc() to allocate memory in non-performer appilication. In that
case, both "printf" work fine.

Any comments are welcome.
David Chan

=======================================================================
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:57:19 PDT

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