From 633f194aa52df3fa85458f70be7d33d35b9dbf01 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 6 Nov 2009 10:56:40 +0000 Subject: cmcfixes66: #i106673# fix memleak --- i18npool/source/textconversion/genconv_dict.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/i18npool/source/textconversion/genconv_dict.cxx b/i18npool/source/textconversion/genconv_dict.cxx index 23a264603df9..3455cfecd3cc 100644 --- a/i18npool/source/textconversion/genconv_dict.cxx +++ b/i18npool/source/textconversion/genconv_dict.cxx @@ -357,8 +357,8 @@ void make_stc_word(FILE *sfp, FILE *cfp) { sal_Int32 count, i, length; sal_Unicode STC_WordData[0x10000]; - Index *STC_WordEntry_S2T = (Index*) malloc(0x10000 * sizeof(Index)); - Index *STC_WordEntry_T2S = (Index*) malloc(0x10000 * sizeof(Index)); + Index STC_WordEntry_S2T[0x10000]; + Index STC_WordEntry_T2S[0x10000]; sal_Int32 count_S2T = 0, count_T2S = 0; sal_Int32 line = 0, char_total = 0; sal_Char Cstr[1024]; @@ -480,7 +480,5 @@ void make_stc_word(FILE *sfp, FILE *cfp) fprintf (cfp, "\tconst sal_uInt16* getSTC_WordEntry_T2S() { return NULL; }\n"); fprintf (cfp, "\tconst sal_uInt16* getSTC_WordIndex_T2S(sal_Int32& count) { count = 0; return NULL; }\n"); } - free(STC_WordEntry_S2T); - free(STC_WordEntry_T2S); } -- cgit v1.2.3 From 3a97ef970ec15962081705be7006ccc2805dedb5 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 6 Nov 2009 11:03:40 +0000 Subject: cmcfixes66: #i106674# fix remaining new[]/delete mismatches --- svtools/source/svdde/ddeml1.cxx | 2 +- svtools/source/svdde/ddesvr.cxx | 2 +- tools/source/fsys/wntmsc.cxx | 2 +- tools/source/stream/strmunx.cxx | 2 +- vcl/os2/source/gdi/salgdi.cxx | 2 +- vcl/os2/source/window/salframe.cxx | 6 +++--- vcl/source/gdi/salmisc.cxx | 8 ++++---- vcl/win/source/window/salframe.cxx | 26 +++++++++++++------------- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/svtools/source/svdde/ddeml1.cxx b/svtools/source/svdde/ddeml1.cxx index 6cc09b612ecf..4b8011627c7d 100644 --- a/svtools/source/svdde/ddeml1.cxx +++ b/svtools/source/svdde/ddeml1.cxx @@ -1089,7 +1089,7 @@ ImpService* ImpDdeMgr::PutService( HSZ hszService ) String aStr( (ULONG)hWndServer ); aStr += pBuf; HSZ hszInstServ = DdeCreateStringHandle( (PSZ)(const char*)pBuf, 850 ); - delete pBuf; + delete [] pBuf; pPtr->hBaseServName = hszService; pPtr->hInstServName = hszInstServ; diff --git a/svtools/source/svdde/ddesvr.cxx b/svtools/source/svdde/ddesvr.cxx index a2124548b4c8..8c72c1713e90 100644 --- a/svtools/source/svdde/ddesvr.cxx +++ b/svtools/source/svdde/ddesvr.cxx @@ -190,7 +190,7 @@ HDDEDATA CALLBACK _export DdeInternal::SvrCallback( pInst->hDdeInstSvr, (LPBYTE) pPairs, sizeof(HSZPAIR) * (nTopics+1), 0, NULL, nCbType, 0); - delete pPairs; + delete [] pPairs; return h; } diff --git a/tools/source/fsys/wntmsc.cxx b/tools/source/fsys/wntmsc.cxx index 0e8e5ebc7918..153fbf37de2e 100644 --- a/tools/source/fsys/wntmsc.cxx +++ b/tools/source/fsys/wntmsc.cxx @@ -91,7 +91,7 @@ struct dirent *readdir( DIR *pDir ) pDir->h = FindFirstFile( pBuf, &pDir->aDirEnt ); bOk = pDir->h != INVALID_HANDLE_VALUE; pDir->p = NULL; - delete pBuf; + delete [] pBuf; } else pDir->h = INVALID_HANDLE_VALUE; diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx index 538c02e78fde..d27fe1f7f2c0 100644 --- a/tools/source/stream/strmunx.cxx +++ b/tools/source/stream/strmunx.cxx @@ -745,7 +745,7 @@ void SvFileStream::Open( const String& rFilename, StreamMode nOpenMode ) aFileCopier.Execute(); } } - delete pBuf; + delete [] pBuf; } } } diff --git a/vcl/os2/source/gdi/salgdi.cxx b/vcl/os2/source/gdi/salgdi.cxx index b6616eb3a24b..082e690c09e7 100644 --- a/vcl/os2/source/gdi/salgdi.cxx +++ b/vcl/os2/source/gdi/salgdi.cxx @@ -1016,7 +1016,7 @@ BOOL Os2SalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* } } - delete pBuf; + delete [] pBuf; return bRet; } diff --git a/vcl/os2/source/window/salframe.cxx b/vcl/os2/source/window/salframe.cxx index 345573b268c3..5e4b843c7cff 100644 --- a/vcl/os2/source/window/salframe.cxx +++ b/vcl/os2/source/window/salframe.cxx @@ -3320,7 +3320,7 @@ static long ImplHandleIMEConversion( Os2SalFrame* pFrame, MPARAM nMP2Param ) if ( pBuf ) { aEvt.maText = XubString( pBuf, (USHORT)nBufLen ); - delete pBuf; + delete [] pBuf; if ( pAttrBuf ) { USHORT nTextLen = aEvt.maText.Len(); @@ -3346,7 +3346,7 @@ static long ImplHandleIMEConversion( Os2SalFrame* pFrame, MPARAM nMP2Param ) } aEvt.mpTextAttr = pSalAttrAry; } - delete pAttrBuf; + delete [] pAttrBuf; } if ( bLastCursor ) aEvt.mnCursorPos = aEvt.maText.Len(); @@ -3358,7 +3358,7 @@ static long ImplHandleIMEConversion( Os2SalFrame* pFrame, MPARAM nMP2Param ) // wieder zerstoeren pFrame->CallCallback( SALEVENT_EXTTEXTINPUT, (void*)&aEvt ); if ( pSalAttrAry ) - delete pSalAttrAry; + delete [] pSalAttrAry; } else pIMEData->mpReleaseIME( hWnd, hIMI ); diff --git a/vcl/source/gdi/salmisc.cxx b/vcl/source/gdi/salmisc.cxx index fc24c0289b50..8b442086eabf 100644 --- a/vcl/source/gdi/salmisc.cxx +++ b/vcl/source/gdi/salmisc.cxx @@ -426,10 +426,10 @@ BitmapBuffer* StretchAndConvert( const BitmapBuffer& rSrcBuffer, const SalTwoRec // memory exception, clean up // remark: the buffer ptr causing the exception // is still NULL here - delete pSrcScan; - delete pDstScan; - delete pMapX; - delete pMapY; + delete[] pSrcScan; + delete[] pDstScan; + delete[] pMapX; + delete[] pMapY; delete pDstBuffer; return NULL; } diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx index 78c4e4e6ddcc..53f822a1e409 100644 --- a/vcl/win/source/window/salframe.cxx +++ b/vcl/win/source/window/salframe.cxx @@ -2158,15 +2158,15 @@ static void ImplSalToTop( HWND hWnd, USHORT nFlags ) if ( nFlags & SAL_FRAME_TOTOP_FOREGROUNDTASK ) { - // This magic code is necessary to connect the input focus of the - // current window thread and the thread which owns the window that - // should be the new foreground window. - HWND hCurrWnd = GetForegroundWindow(); - DWORD myThreadID = GetCurrentThreadId(); - DWORD currThreadID = GetWindowThreadProcessId(hCurrWnd,NULL); - AttachThreadInput(myThreadID, currThreadID,TRUE); - SetForegroundWindow(hWnd); - AttachThreadInput(myThreadID,currThreadID,FALSE); + // This magic code is necessary to connect the input focus of the + // current window thread and the thread which owns the window that + // should be the new foreground window. + HWND hCurrWnd = GetForegroundWindow(); + DWORD myThreadID = GetCurrentThreadId(); + DWORD currThreadID = GetWindowThreadProcessId(hCurrWnd,NULL); + AttachThreadInput(myThreadID, currThreadID,TRUE); + SetForegroundWindow(hWnd); + AttachThreadInput(myThreadID,currThreadID,FALSE); } if ( nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN ) @@ -5436,7 +5436,7 @@ static BOOL ImplHandleIMECompositionInput( WinSalFrame* pFrame, WCHAR* pTextBuf = new WCHAR[nTextLen]; ImmGetCompositionStringW( hIMC, GCS_RESULTSTR, pTextBuf, nTextLen*sizeof( WCHAR ) ); aEvt.maText = XubString( reinterpret_cast(pTextBuf), (xub_StrLen)nTextLen ); - delete pTextBuf; + delete [] pTextBuf; } aEvt.mnCursorPos = aEvt.maText.Len(); @@ -5462,7 +5462,7 @@ static BOOL ImplHandleIMECompositionInput( WinSalFrame* pFrame, WCHAR* pTextBuf = new WCHAR[nTextLen]; ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf, nTextLen*sizeof( WCHAR ) ); aEvt.maText = XubString( reinterpret_cast(pTextBuf), (xub_StrLen)nTextLen ); - delete pTextBuf; + delete [] pTextBuf; WIN_BYTE* pAttrBuf = NULL; LONG nAttrLen = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, 0, 0 ); @@ -5498,7 +5498,7 @@ static BOOL ImplHandleIMECompositionInput( WinSalFrame* pFrame, } aEvt.mpTextAttr = pSalAttrAry; - delete pAttrBuf; + delete [] pAttrBuf; } } @@ -5535,7 +5535,7 @@ static BOOL ImplHandleIMECompositionInput( WinSalFrame* pFrame, } if ( pSalAttrAry ) - delete pSalAttrAry; + delete [] pSalAttrAry; } return !bDef; -- cgit v1.2.3 From f213a6f615501541dcee0ff34d8b49ee87354026 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 9 Nov 2009 09:59:57 +0000 Subject: cmcfixes66: #i106673# arrays don't fit in windows default stack --- i18npool/source/textconversion/genconv_dict.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/i18npool/source/textconversion/genconv_dict.cxx b/i18npool/source/textconversion/genconv_dict.cxx index 3455cfecd3cc..a49bf3031bbc 100644 --- a/i18npool/source/textconversion/genconv_dict.cxx +++ b/i18npool/source/textconversion/genconv_dict.cxx @@ -39,6 +39,8 @@ #include #include +#include + using namespace ::rtl; void make_hhc_char(FILE *sfp, FILE *cfp); @@ -357,8 +359,8 @@ void make_stc_word(FILE *sfp, FILE *cfp) { sal_Int32 count, i, length; sal_Unicode STC_WordData[0x10000]; - Index STC_WordEntry_S2T[0x10000]; - Index STC_WordEntry_T2S[0x10000]; + std::vector STC_WordEntry_S2T(0x10000); + std::vector STC_WordEntry_T2S(0x10000); sal_Int32 count_S2T = 0, count_T2S = 0; sal_Int32 line = 0, char_total = 0; sal_Char Cstr[1024]; @@ -416,7 +418,7 @@ void make_stc_word(FILE *sfp, FILE *cfp) sal_uInt16 STC_WordIndex[0x100]; if (count_S2T > 0) { - qsort(STC_WordEntry_S2T, count_S2T, sizeof(Index), Index_comp); + qsort(&STC_WordEntry_S2T[0], count_S2T, sizeof(Index), Index_comp); fprintf(cfp, "\nstatic const sal_uInt16 STC_WordEntry_S2T[] = {"); count = 0; @@ -449,7 +451,7 @@ void make_stc_word(FILE *sfp, FILE *cfp) } if (count_T2S > 0) { - qsort(STC_WordEntry_T2S, count_T2S, sizeof(Index), Index_comp); + qsort(&STC_WordEntry_T2S[0], count_T2S, sizeof(Index), Index_comp); fprintf(cfp, "\nstatic const sal_uInt16 STC_WordEntry_T2S[] = {"); count = 0; -- cgit v1.2.3