[Dev] Re: [TriLUG] anybody use pointers and shared memory?

H Brett Bolen wingedlizard at nc.rr.com
Sat Jun 1 13:17:16 EDT 2002


Serendipity strikes again.

I was playing with info pages using kde, and
I found mmalloc.

This looks like what you are asking for, let me
know how it works out.


b\375

H Brett Bolen wrote:7
> John F Davis wrote:
> 
>> Hello
>>
>> I know how to use shared memory between processes via shmget and 
>> shmat, but
>> I'm not an expert on their use.  (I've used it for simple flat 
>> structures.)
>> Anybody have any experience using them with something similar to malloc'd
>> pointers?  For instance, if I want to dynamically allocate data that is
>> shared, do I have to use shmget/shmat in lieu of malloc?
>>
> 
> Hey John,
> 
> There is a very simple wrapper class, SharedArray,  here:
> 
>  http://www.pressenter.com/~3nelsons/joecode/
> 
> it's implemented in the header file, and is easy to use.  as long as
> the destructors are called, everything is cleaned up.
> 
> use is as simple as
> 
>   typedef struct {
>     ...
>   } MyStruct;
> 
>   MyStruct *MyStructArray = new SharedArray< MyStruct> ( "Name", 100);
> 
>   MyStructArray[1] = ...
> 
>   delete MyStructArray;
> 
> may not be exact, but close.
> 
> 
> b\375
> 
> ps:  I'm forwarding this to dev at trilug.org
> 
> _______________________________________________
> Dev mailing list
> Dev at trilug.org
> http://www.trilug.org/mailman/listinfo/dev
> 






More information about the TriLUG mailing list