Segementation Problem while accessing contents from Memory Mapped File

N

nkrisraj

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top