View Single Post
  #5  
Old 07-28-2014, 16:08
SLV SLV is offline
Friend
 
Join Date: May 2005
Posts: 62
Rept. Given: 3
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 5
Thanks Rcvd at 2 Times in 2 Posts
SLV Reputation: 4
SESE is very userful for debugging and preventing memory/handle leaks. My lovely construction is:

Code:
VOID
RoutineName(
   PVOID Arg0
   )
{
   HANDLE hFile = INVALID_HANDLE_VALUE;
   PVOID  pMem  = NULL;

   do
   {
      if (!Arg0) 
      {
         DebugRoutine(__FILE__, __LINE__, ...
         break;
      }

      hFile = ...
      pMem = ...

   } while (FALSE);

   if (hFile != INVALID_HANDLE_VALUE) {
      CloseHandle(hFile);
   }

   if (pMem) {
      ...
}
Reply With Quote