08-16-2005 08:03 AM
08-16-2005 08:41 AM
If you run the program in the debug mode you should get some useful clues as to what is going on.
JR
08-16-2005 08:50 AM
hello JR
Thanks...My application is in debug mode. and i have put the break point where i am getting this error. When i take the cursor over the variable before executining i find expected value in array but as soon as i execute that perticular statement i get an error.
for (channelNumber =0;channelNumber<PSPU1Channels;channelNumber++)
{
strcpy(PSChNum, PSPU1ChannelNum[channelNumber]);
08-16-2005 09:03 AM
I am sorry by mistake "Submit Post" clicked..
hello JR
Thanks...My application is in debug mode. and i have put the break point where i am getting this error. When i take the cursor over the variable before executining i find expected value in array but as soon as i execute that perticular statement i get an error.
for (channelNumber =0;channelNumber<PSPU1Channels;channelNumber++)
{
// strcpy(PSChNum, channels.PSPU1PSNum[channelNumber]); //Original statement here PSPU1ChannelNum[channelNumber] show NULL this is the // case where memory allocated dynamically and channels.PSPU1PSNum[channelNumber] show NULL before executing this statment
strcpy(PSChNum, PSPU1ChannelNum[channelNumber]); //Modified PSPU1ChannelNum[channelNumber] shows the expected value executing this statement PSPU1ChannelNum[channelNumber] is a two dimensional array of char (char PSPU1ChannelNum[64][5]; )
.................
.............
}
I have very similar one more block where i don't find any error.
Thanks and Regards
Rakesh
08-16-2005 10:38 AM
At the risk of losing more brownie points
What is the typical content of the strings you are copying? If they are not terminated with a \0 character then strcpy() will not stop copying bytes until it finds one somewhere - this is often a source of unexpected program crashes, as the function just ploughs on, creating havoc by overwriting data or even running off the end of the memory space allocated to the program. You could use strncpy() to limit the number of characters copied.
JR
08-17-2005 01:55 AM
08-17-2005 03:20 AM
Perhaps if you posted some more of your source code it might be a bit clearer as to what is supposed to be happening?
JR
08-17-2005 08:57 AM
Hello JR
As suggested i am attaching the source code of my application. Please refer function LogPSStatus() in Datalogging.c. By using fixed defined array of string (PSPU1ChannelNum) i don't find GPF Error. I am sorry for my previous comments in which i had mentioned of persistence of error in 2nd case. That time i have not used "strncpy()" function all the places so i was getting GPF Error. Now please help me to investigate GPF error as i intend to allocated memory dynamically.
Thanks and Regards
Rakesh
08-17-2005 11:00 AM
RKGupta wrote:
<snip>
channels.PSPU1PSNum[channelNumber] show NULL before executing this statment
<snip>
This is clearly the cause of the GPF; the problem is I cannot see why this pointer should be NULL - after all you appear to calloc adequately on line 1400 of ParseConfigFiles.c. Two things spring to mind:
Unfortunately I could not build the program on my PC (missing files) so I was not able to see the GPF in action. Maybe if you set a breakpoint at line 1406 and check that all the allocations have succeeded? At what value of the loop counter channelNumber does the GPF occur? Does this give you any clues?
Good luck!
JR
08-18-2005 03:58 AM