hi,
i have a problem in storing the data in allocated memory using malloc.
i have structure to store huge data form the serial port.
Code:
typedef struct FileData {
unsigned char *FRdata;
struct FileData *next;
}FileData;
/*I store the data in FileData->FRdata, by allocating sufficient memory to it*/
Datacur->FRdata=(char *)malloc(sizeof(max_bytes));
for(j=0;bytes_to_read>0;j++,bytes_to_read--)
Datacur->FRdata[j]=*Ftemp++;
Datacur->next=NULL;
i have to write the raw data from the serial port in to file after converting the raw into its format[ the data format is usually float type].
when i print few data before opening a file
Code:
j=0;
printf("read");
while(j<10){
printf("%02x ",Datahead->FRdata[j++]);
}
there is no change in the data .
The problem is after , file is opened
Code:
fptr=fopen(Surveyname,"wt");
the data in the allocated memory{Datahead->FRdata[} has changed { the data that is written to file is different to that of original data.}
where cud be the malicious alteration hapened.
any help on this.