I am passing a void *
as an argument to a function foo(void* parm)
which calls function bar(STmyStruct* parm)
Should I cast the void pointer to STmyStruct*
or create a new struct, memcpy what the void*
points to and then pass a pointer to that struct?
I guess solution A is more efficient?
A: foo(void* parm)
{
bar((STmyStruct*) parm)
}
B: foo(void* parm)
{
STmyStruct myStr;
memcpy(&myStr, parm, sizeof(STmyStruct));
bar(&myStr)
}
bar(STmyStruct* mystr);
No comments:
Post a Comment