Re: pfMalloc & object container

New Message Reply Date view Thread view Subject view Author view

Scott McMillan (mcmillan++at++cambridge.com)
Tue, 28 Apr 1998 12:39:11 -0400


Jay Gischer wrote:
>
> David Chan writes:
> > HI,
> > I have a problem with pfMalloc when I am using pfMalloc to create
> > a shared memory. Here is my simple code:
> >
> > shared=(SharedData *)pfMalloc(sizeof(SharedData),
> > pfGetSharedArena());
> >
> > while SharedData is a typedef structure, and inside SharedData, there is a
> > Class container:
> >
> > typedef structure {
> > ....
> > Console *console[10];
> > ....
> > } SharedData;
> >
> > Where Class "Console" is an abstract class, the array is to store derived
> > class from "Console".
> > I can create an object and assign it into the array, but after
> > that, when I want to access the object's public function like this:
> >
> > shared->console[0]->
> >
> > It is always segmentation falut.
>
> I don't think that pointers work too well with shared memory here.
> If the Console's were allocated from shared memory, their addresses
> will possibly change from process to process. If they weren't the
> memory won't even be there in a different process.

I have never had a problem with abstract base class pointers in
shared memory, provided the derived class is allocated out of
the same shared arena. I believe I had to write a new operator for
the class to accomplish this, but my memory is a bit fuzzy.

scott

P.S. I vote you use CC to link as well. Using cc to link is
a nasty carryover from old Performer makefiles.

-- 
Scott McMillan                   mailto:mcmillan++at++cambridge.com
Cambridge Research Associates    Ministry of Silly Walks
1430 Spring Hill Road, Ste. 200  Voice: (703) 790-0505 x7235
McLean, VA 22102                 Fax:   (703) 790-0370
=======================================================================
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:18 PDT

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