RChunk read write

Login to reply to this topic.
Sun, 2007-10-21 22:42
Joined: 2007-09-04
Forum posts: 19

Hi All,

I am using RChunk i.e. shared memory. I have to store a pointer address into this shared memory.
The code for using RChunk is:
RChunk a;
TInt handle= a.CreateLocal(1024,1024,EOwnerProcess);
TUint8 *m =a.Base();

Now I want to store a pointer address into RChunk. Can somebody tell me in detail how can i read and write pointer from RChunk.
e.g. I am using Pointer to a object i.e.
A* a;

and i want to use a pointer into Shared memory i.e. RChunk. How can I read and write this pointer to RChunk.


Mon, 2007-10-22 09:19
Joined: 2004-11-29
Forum posts: 1246
Re: RChunk read write

No different from using pointers pointing anywhere else.

A* myobj = new A();
A* storage = (A*)a.Base();

*storage = *myobj; // Store at beginning of chunk

Mon, 2007-10-22 09:20
Joined: 2004-11-29
Forum posts: 1246
Re: RChunk read write

Though, possibly easier, you can also create a new heap connected to the chunk, by creating the chunk (and heap) through User::ChunkHeap();

Then you can switch to the heap with User::SwitchHeap() and the normal new and delete will work on your new chunks heap, until you switch back.

  • Login to reply to this topic.