From e052b025f25a267391565aea735ef6f70591ea1f Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 9 Oct 2014 12:54:29 +0000 Subject: [PATCH] [SHELL32] * Fix another comment. * Fix a cch/cb bug. * Make use of the DSA_DestroyCallback function instead of messing around with the internals of the DSA. CORE-8564 svn path=/branches/shell-experiments/; revision=64646 --- dll/win32/shell32/shlfileop.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dll/win32/shell32/shlfileop.cpp b/dll/win32/shell32/shlfileop.cpp index 2138ef1c73c..22a03b11053 100644 --- a/dll/win32/shell32/shlfileop.cpp +++ b/dll/win32/shell32/shlfileop.cpp @@ -970,12 +970,12 @@ static DWORD _ConvertAtoW(PCSTR strSrc, PCWSTR* pStrDest, BOOL isList) sizeA = lstrlenA(strSrc) + 1; } - // Measure the + // Measure the needed allocation size. int sizeW = MultiByteToWideChar(CP_ACP, 0, strSrc, sizeA, NULL, 0); if (!sizeW) return GetLastError(); - PWSTR strDest = (PWSTR) HeapAlloc(GetProcessHeap(), 0, sizeW); + PWSTR strDest = (PWSTR) HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR)); if (!strDest) return ERROR_OUTOFMEMORY; @@ -1739,7 +1739,16 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) return ret; } -#define SHDSA_GetItemCount(hdsa) (*(int*)(hdsa)) +// Used by SHFreeNameMappings +static int CALLBACK _DestroyCallback(void *p, void *pData) +{ + LPSHNAMEMAPPINGW lp = (SHNAMEMAPPINGW *)p; + + SHFree(lp->pszOldPath); + SHFree(lp->pszNewPath); + + return TRUE; +} /************************************************************************* * SHFreeNameMappings [shell32.246] @@ -1757,16 +1766,7 @@ void WINAPI SHFreeNameMappings(HANDLE hNameMapping) { if (hNameMapping) { - int i = SHDSA_GetItemCount((HDSA)hNameMapping) - 1; - - for (; i>= 0; i--) - { - LPSHNAMEMAPPINGW lp = (SHNAMEMAPPINGW *)DSA_GetItemPtr((HDSA)hNameMapping, i); - - SHFree(lp->pszOldPath); - SHFree(lp->pszNewPath); - } - DSA_Destroy((HDSA)hNameMapping); + DSA_DestroyCallback((HDSA) hNameMapping, _DestroyCallback, NULL); } }