CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 19

Threaded View

  1. #14
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Invalid access to memory location using GlobalFree

    What's this critical section for?
    Code:
    EnterCriticalSection(&l_statcheck);
    if (l_State == TRUE) {
    	exit(ShowError(ERR_HEARTBEAT));
    }
    LeaveCriticalSection(&l_statcheck);
    No variable is being directly being assigned to. A comparison is done, and then a call to exit().

    If ShowError for some reason needs to be synchronized, then that is where the critical section would be placed, and not at this level. Otherwise I see no need for the critical section -- this is paranoid programming by someone who didn't understand how and when to use synchronization objects.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; January 18th, 2013 at 09:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured