Dyanamic malloc using shared memory.

Discussion in 'C' started by JaysinghSamuel, Dec 11, 2008.

  1. JaysinghSamuel

    JaysinghSamuel New Member

    Dec 11, 2008
    Likes Received:
    Trophy Points:
    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;


    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,

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice