Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Dyanamic malloc using shared memory. (http://www.go4expert.com/forums/dyanamic-malloc-using-shared-memory-t15461/)

JaysinghSamuel 11Dec2008 13:26

Dyanamic malloc using shared memory.
 
Hi all,

I need to dynamic create space for these structure and store the hash entries and datas.
typedef struct abc{
hash_t *table;
} gInfoDB;

typedef struct xyz{
gInfoDB *ctDB;
} InfoDB;

InfoDB[10000];

I have 10000 of InfoDB array in which the ctDB is malloced dynamically and store the contents of the files in
the hash table.

My question is:

1.The shared memory with which we get a chunk of memory. Can we further malloc and store
the data's given by the shared memory. or we need to create keys and
shared memory for every arrays.

I have tried for arrays of structure and its works fine. But i was not able to do this.

struct check {
int *datum;
} *strucSup;

Here i was trying to malloc the datum and was able to store the data but getting segFault when tring through some other process. I can use further shmget the datum pointer but i don't want to do because this may create so many shared memory in my systems.

Is there any work around to do this.

Please guide me with the coding if you get.

Thanks in advance,
Jaysingh.


All times are GMT +5.5. The time now is 09:37.