I have main update where I do access control before call. I would like to use one place in my code where call any urgent funcs.
I have a struct ACTION:
{
FUNC_PROTOTYPE pfnAction;
unsigned int argsnum;
va_list argsval;
};
When I need invoke func, I do:
1 Put func and arguments to queue; 2 Pop them on the next update
{
ACTION action;
while(!Queue_isEmpty())
{ // check and pop urgent functions
if(Queue_Pop(&action))
{
action.pfnAction(action.argsnum, action.args);
va_end(action.args);
}
}
}
For example, I try to call
void func(unsigned int argsnum, va_list args)
But my args inside func is corrupted.
I thought, that problem while I'm pop from queue:
Queue_Pop(P_ACTION p_res)
{
if(!Queue_isEmpty())
{
p_res->pfnAction = header->pfnAction;
p_res->argsnum = header->argsnum;
if(0 < p_res->argsnum)
{
p_res->argsval = header->argsval;
va_end(header->argsval);
}
...
}
}
But action.args is fine.