S
Songling
Hi,
Please help to check if the following code is safe.
void* dequeue(MSG_Q_ID q_ptr)
{
U32 msg_ptr = 0;
if (msgQReceive((q_ptr), (char*) &msg_ptr, 4, 0) >=0)
{
return((void*) msg_ptr);
}
return NULL;
}
int main(void)
{
// get qid....
MyType *my_ptr = (MyType *) dequeue( qid);
// process dequeued msg through my_ptr....
}
I thought that after dequeue() returns, msg_ptr is deallocated from the
stack, and
my_ptr is pointing to some invalid memory space. But seems like the code
works
fine. So is this a real problem?
Thanks,
Songling
Please help to check if the following code is safe.
void* dequeue(MSG_Q_ID q_ptr)
{
U32 msg_ptr = 0;
if (msgQReceive((q_ptr), (char*) &msg_ptr, 4, 0) >=0)
{
return((void*) msg_ptr);
}
return NULL;
}
int main(void)
{
// get qid....
MyType *my_ptr = (MyType *) dequeue( qid);
// process dequeued msg through my_ptr....
}
I thought that after dequeue() returns, msg_ptr is deallocated from the
stack, and
my_ptr is pointing to some invalid memory space. But seems like the code
works
fine. So is this a real problem?
Thanks,
Songling