Segementation Problem while accessing contents from Memory Mapped File

Discussion in 'C Programming' started by nkrisraj@gmail.com, Jan 10, 2006.

  1. Guest

    Hi,

    I have a following structure:
    typedef struct
    {
    RateData rdr;
    int RateID;
    char RateBalance;

    } RateInfo;

    typedef struct
    {
    DayRates *dr;
    WeekRates *wr;

    } RateData;

    First I will create the memoefy for the DayRates, WeekRates structures
    inside the RateInfo structure variable. After that Iam going to copy
    the contents into DayRates, WeekRatesstructures. Once the all the
    structure members inside RateInfo structure variable are initialized, I
    will add that node to a AVL tree. This way, Iam going to create an AVL
    tree by adding RateInfo nodes to it. Once the total tree is contructed,
    I will store this tree as file (rateinfo.map) on the disk.

    In my next programming component, Iam going to load this file
    (rateinfo.map) into memory using mmap() function call. Once I load the
    file into memory using mmap(), Iam able to access the RateID and
    RateBalance members of the RateInfo. But, Iam not able to access the
    DayRates, and WeekRates structure contents. When I try to access the
    members of DayRates , and WeekRates structures, my program is showing
    segmentation fault and Iam getting the core dump.

    Even though I allocated memory for DayRates , and WeekRates structures
    inside RateInfo node while creating the tree, why Iam not able to
    access contents of DayRates , and WeekRates structures when I mmap()
    file into memory?

    Any pointers would be a great help.

    Thanks,
    -Nikhil
    , Jan 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    300
    Walter Roberson
    Jan 10, 2006
  2. Replies:
    8
    Views:
    405
    Keith Thompson
    Jan 10, 2006
  3. didier2309

    segementation fault

    didier2309, May 9, 2006, in forum: C Programming
    Replies:
    23
    Views:
    693
    Keith Thompson
    May 11, 2006
  4. priyanka

    segementation fault

    priyanka, Jul 18, 2006, in forum: C Programming
    Replies:
    7
    Views:
    285
    Keith Thompson
    Jul 19, 2006
  5. Chris Brooks

    memory mapped tar file contents

    Chris Brooks, Nov 13, 2008, in forum: Python
    Replies:
    1
    Views:
    364
    Aaron Brady
    Nov 13, 2008
Loading...

Share This Page