Chris Ahrendt wrote: > fail: > if(wined3d_fake_gl_context_hdc) > ReleaseDC(wined3d_fake_gl_context_hwnd, > wined3d_fake_gl_context_hdc); > wined3d_fake_gl_context_hdc = NULL; > if(wined3d_fake_gl_context_hwnd) > DestroyWindow(wined3d_fake_gl_context_hwnd); > wined3d_fake_gl_context_hwnd = NULL; > if(glCtx) pwglDeleteContext(glCtx); > LeaveCriticalSection(&wined3d_fake_gl_context_cs); > return FALSE; > > into a routine and then do a > > return fakeContextFail(glCtx);
That will turn into nightmare when tracking a locking problem down. Call to LeaveCriticalSection should always be in the same function as EnterCriticalSection. Same applies to any resource that you do not want to leak. That is much more important then calling a function a "routine" and replacing all goto's with that function call. Also I'd like to show how you can free local variables?