I tried to explain it all in the title: I have a multithreaded C program which will have multiple windows calling one Window Procedure.
There is some processing done in the window procedure. Do I need to protect it, or will each call to the window procedure be separated in memory?
My instinct is that I don’t need a mutex, because they’re all local variables, is this wrong?
LRESULT APIENTRY EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_GETDLGCODE)
return DLGC_WANTALLKEYS;
else if(uMsg == WM_CHAR)
{
if( (int) wParam == 13)
{
char* strCurrentCommand;
unsigned long ulThisConversation = GetConversation(0, 0, hwnd, 0, 0);
...
I’m concerned with the local variables strCurrentCommand and ulThisConversation.
Local variables and parameters to functions go on the stack. Each thread gets its own stack, and each invocation of a function gets a space on the stack of the thread it’s running in for its parameters and local variables. So you’re fine.