IPC msgrcv - writing overflows memory extra 4 bytes
Hi
I have the following structure:
#define ZZ_SIMMSG_DATA_SIZE 1000
struct T_simmsg
{
long mtype;
int src;
int dest;
int length; // length of used data area
union
{
int ex_num;
int display_num;
};
unsigned char data[ZZ_SIMMSG_DATA_SIZE];
};
In another file I have the following code:
struct T_simmsg rx_msg
result = msgrcv(msqid, &rx_msg, sizeof(rx_msg), ZZ_TASK_STARTED, IPC_NOWAIT);
I am using a memory tool check that checks for memory leaks, write and read overflows etc...
The above code causes a "writing overflows memory" error. Where the rx_msg has a size of 1020 my program seems to want to write 1024? Whatever the value of 'ZZ_SIMMSG_DATA_SIZE + 20' there is always an extra 4 bytes.
When I put a printf statement for the size of rx_msg it returns 'ZZ_SIMMSG_DATA_SIZE + 20', as expected
Can anyone tell me why?? and how do I fix it
thank you
Tara
Last edited by tara; 11-08-2005 at 11:19 PM.
|