From 152da8847e828b132c5753ae5f58e8272556d4ef Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Mar 2013 11:15:15 +0000 Subject: some another leaks fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@4070 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/YAMN/src/debug.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'plugins/YAMN') diff --git a/plugins/YAMN/src/debug.cpp b/plugins/YAMN/src/debug.cpp index 1f19975586..c459d0cbb7 100644 --- a/plugins/YAMN/src/debug.cpp +++ b/plugins/YAMN/src/debug.cpp @@ -15,7 +15,7 @@ //-------------------------------------------------------------------------------------------------- TCHAR DebugUserDirectory[MAX_PATH] = _T("."); -LPCRITICAL_SECTION FileAccessCS; +CRITICAL_SECTION FileAccessCS; #ifdef DEBUG_SYNCHRO TCHAR DebugSynchroFileName2[]=_T("%s\\yamn-debug.synchro.log"); @@ -40,11 +40,7 @@ void InitDebug() #if defined (DEBUG_SYNCHRO) || defined (DEBUG_COMM) || defined (DEBUG_DECODE) TCHAR DebugFileName[MAX_PATH]; #endif - if (FileAccessCS==NULL) - { - FileAccessCS=new CRITICAL_SECTION; - InitializeCriticalSection(FileAccessCS); - } + InitializeCriticalSection(&FileAccessCS); #ifdef DEBUG_SYNCHRO _stprintf(DebugFileName,DebugSynchroFileName2,DebugUserDirectory); @@ -70,6 +66,7 @@ void InitDebug() void UnInitDebug() { + DeleteCriticalSection(&FileAccessCS); #ifdef DEBUG_SYNCHRO DebugLog(SynchroFile,"File is being closed normally."); CloseHandle(SynchroFile); @@ -99,10 +96,10 @@ void DebugLog(HANDLE File,const char *fmt,...) while(_vsnprintf(str,strsize,fmt,vararg)==-1) str=(char *)realloc(str,strsize+=65536); va_end(vararg); - EnterCriticalSection(FileAccessCS); + EnterCriticalSection(&FileAccessCS); WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL); WriteFile(File,str,(DWORD)strlen(str),&Written,NULL); - LeaveCriticalSection(FileAccessCS); + LeaveCriticalSection(&FileAccessCS); free(str); } @@ -120,10 +117,10 @@ void DebugLogW(HANDLE File,const WCHAR *fmt,...) while(_vsnwprintf(str,strsize,fmt,vararg)==-1) str=(WCHAR *)realloc(str,(strsize+=65536)*sizeof(WCHAR)); va_end(vararg); - EnterCriticalSection(FileAccessCS); + EnterCriticalSection(&FileAccessCS); WriteFile(File,tids,(DWORD)strlen(tids),&Written,NULL); WriteFile(File,str,(DWORD)wcslen(str)*sizeof(WCHAR),&Written,NULL); - LeaveCriticalSection(FileAccessCS); + LeaveCriticalSection(&FileAccessCS); free(str); } -- cgit v1.2.3