chee0007
September 18th, 2007, 10:58 PM
Hi guys
From what i have learnt, a static function cannot reference to outside variables directly except variables that is declared inside the static function itself.
So by calling another function that actually do all the thread procedures, I can change and manipulate variables directly without using pointers and such.
But if i do that, will it cause any memory leaks or disadvantages?
see codes below...
static UINT __cdecl MyThreadStatic(void *p);
UINT MyThread();
UINT __cdecl MyClass::MyThreadStatic(void *p)
{
return ( ( (MyClass*) p ) ->MyThread() )
}
UINT MyClass::MyThread()
{
while(1)
{//do some stuff}
return 0;
}
From what i have learnt, a static function cannot reference to outside variables directly except variables that is declared inside the static function itself.
So by calling another function that actually do all the thread procedures, I can change and manipulate variables directly without using pointers and such.
But if i do that, will it cause any memory leaks or disadvantages?
see codes below...
static UINT __cdecl MyThreadStatic(void *p);
UINT MyThread();
UINT __cdecl MyClass::MyThreadStatic(void *p)
{
return ( ( (MyClass*) p ) ->MyThread() )
}
UINT MyClass::MyThread()
{
while(1)
{//do some stuff}
return 0;
}