[PATCH 2/5] shell32/tests: Get rid of SHGetMalloc() in tests.
Nikolay Sivov
nsivov at codeweavers.com
Mon Jan 6 15:08:22 CST 2020
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/shell32/tests/shelllink.c | 12 +++-------
dlls/shell32/tests/shellpath.c | 23 +++---------------
dlls/shell32/tests/shlfolder.c | 43 +++++++++++++++-------------------
3 files changed, 25 insertions(+), 53 deletions(-)
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index db839200d5..f760990a0a 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -492,13 +492,10 @@ void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int save_fails)
lok(str != NULL ||
broken(str == NULL), /* shell32 < 5.0 */
"Didn't expect NULL\n");
- if (str != NULL)
+ if (str)
{
- IMalloc *pmalloc;
-
lok(!wcscmp(path, str), "Expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(str));
- SHGetMalloc(&pmalloc);
- IMalloc_Free(pmalloc, str);
+ CoTaskMemFree(str);
}
else
win_skip("GetCurFile fails on shell32 < 5.0\n");
@@ -550,11 +547,8 @@ static void check_lnk_(int line, const WCHAR* path, lnk_desc_t* desc, int todo)
"Didn't expect NULL\n");
if (str != NULL)
{
- IMalloc *pmalloc;
-
lok(!wcscmp(path, str), "Expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(str));
- SHGetMalloc(&pmalloc);
- IMalloc_Free(pmalloc, str);
+ CoTaskMemFree(str);
}
else
win_skip("GetCurFile fails on shell32 < 5.0\n");
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 8161330b1e..9ec7226312 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -90,7 +90,6 @@ static BOOL (WINAPI *pSHGetSpecialFolderPathA)(HWND, LPSTR, int, BOOL);
static HRESULT (WINAPI *pSHGetSpecialFolderLocation)(HWND, int, LPITEMIDLIST *);
static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
static int (WINAPI *pSHFileOperationA)(LPSHFILEOPSTRUCTA);
-static HRESULT (WINAPI *pSHGetMalloc)(LPMALLOC *);
static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
static HRESULT (WINAPI *pSHGetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR *);
static HRESULT (WINAPI *pSHSetKnownFolderPath)(REFKNOWNFOLDERID, DWORD, HANDLE, PWSTR);
@@ -100,7 +99,6 @@ static HRESULT (WINAPI *pSHGetKnownFolderIDList)(REFKNOWNFOLDERID, DWORD, HANDLE
static BOOL (WINAPI *pPathResolve)(PWSTR, PZPCWSTR, UINT);
static DLLVERSIONINFO shellVersion = { 0 };
-static LPMALLOC pMalloc;
static const BYTE guidType[] = { PT_GUID };
static const BYTE controlPanelType[] = { PT_SHELLEXT, PT_GUID, PT_CPL };
static const BYTE folderType[] = { PT_FOLDER, PT_FOLDERW };
@@ -202,20 +200,10 @@ static void loadShell32(void)
if (!pILFindLastID)
pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
GET_PROC(SHFileOperationA)
- GET_PROC(SHGetMalloc)
GET_PROC(PathYetAnotherMakeUniqueName)
GET_PROC(SHGetKnownFolderIDList)
GET_PROC(PathResolve);
- ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
- if (pSHGetMalloc)
- {
- HRESULT hr = pSHGetMalloc(&pMalloc);
-
- ok(hr == S_OK, "SHGetMalloc failed: 0x%08x\n", hr);
- ok(pMalloc != NULL, "SHGetMalloc returned a NULL IMalloc\n");
- }
-
if (pDllGetVersion)
{
shellVersion.cbSize = sizeof(shellVersion);
@@ -1319,13 +1307,11 @@ static void test_parameters(void)
pidl = NULL;
hr = SHGetFolderLocation(NULL, 0xeeee, NULL, 0, &pidl);
ok(hr == E_INVALIDARG, "got 0x%08x, expected E_INVALIDARG\n", hr);
- if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
/* check a bogus user token: */
pidl = NULL;
hr = SHGetFolderLocation(NULL, CSIDL_FAVORITES, (HANDLE)2, 0, &pidl);
ok(hr == E_FAIL || hr == E_HANDLE, "got 0x%08x, expected E_FAIL or E_HANDLE\n", hr);
- if (hr == S_OK) IMalloc_Free(pMalloc, pidl);
/* a NULL pidl pointer crashes, so don't test it */
@@ -1387,7 +1373,7 @@ static BYTE testSHGetFolderLocation(int folder)
getFolderName(folder));
if (pidlLast)
ret = pidlLast->mkid.abID[0];
- IMalloc_Free(pMalloc, pidl);
+ ILFree(pidl);
}
}
@@ -1416,7 +1402,7 @@ static BYTE testSHGetSpecialFolderLocation(int folder)
"%s: ILFindLastID failed\n", getFolderName(folder));
if (pidlLast)
ret = pidlLast->mkid.abID[0];
- IMalloc_Free(pMalloc, pidl);
+ ILFree(pidl);
}
}
return ret;
@@ -1546,7 +1532,7 @@ static void matchGUID(int folder, const GUID *guid, const GUID *guid_alt)
"%s: got GUID %s, expected %s or %s\n", getFolderName(folder),
wine_dbgstr_guid(shellGuid), wine_dbgstr_guid(guid), wine_dbgstr_guid(guid_alt));
}
- IMalloc_Free(pMalloc, pidl);
+ ILFree(pidl);
}
}
@@ -1702,7 +1688,6 @@ static void doChild(const char *arg)
hr = SHGetFolderLocation(NULL, CSIDL_FAVORITES, NULL, 0, &pidl);
ok(hr == E_FAIL || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
"SHGetFolderLocation returned 0x%08x\n", hr);
- if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
ok(!pSHGetSpecialFolderPathA(NULL, path, CSIDL_FAVORITES, FALSE),
"SHGetSpecialFolderPath succeeded, expected failure\n");
@@ -1712,8 +1697,6 @@ static void doChild(const char *arg)
ok(hr == E_FAIL || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),
"SHGetFolderLocation returned 0x%08x\n", hr);
- if (hr == S_OK && pidl) IMalloc_Free(pMalloc, pidl);
-
/* now test success: */
hr = pSHGetFolderPathA(NULL, CSIDL_FAVORITES | CSIDL_FLAG_CREATE, NULL,
SHGFP_TYPE_CURRENT, path);
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index ebeaf4e20e..3918a4387c 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -44,8 +44,6 @@
DEFINE_GUID(IID_IParentAndItem, 0xB3A4B685, 0xB685, 0x4805, 0x99,0xD9, 0x5D,0xEA,0xD2,0x87,0x32,0x36);
DEFINE_GUID(CLSID_ShellDocObjView, 0xe7e4bc40, 0xe76a, 0x11ce, 0xa9,0xbb, 0x00,0xaa,0x00,0x4a,0xe8,0x37);
-static IMalloc *ppM;
-
static HRESULT (WINAPI *pSHCreateItemFromIDList)(PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv);
static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR,IBindCtx*,REFIID,void**);
static HRESULT (WINAPI *pSHCreateItemFromRelativeName)(IShellItem*,PCWSTR,IBindCtx*,REFIID,void**);
@@ -149,9 +147,6 @@ static void init_function_pointers(void)
hmod = GetModuleHandleA("kernel32.dll");
pIsWow64Process = (void*)GetProcAddress(hmod, "IsWow64Process");
-
- hr = SHGetMalloc(&ppM);
- ok(hr == S_OK, "SHGetMalloc failed %08x\n", hr);
}
/* Based on PathAddBackslashW from dlls/shlwapi/path.c */
@@ -405,7 +400,7 @@ static void test_EnumObjects(IShellFolder *iFolder)
}
for (i=0;i<5;i++)
- IMalloc_Free(ppM, idlArr[i]);
+ ILFree(idlArr[i]);
}
static void test_BindToObject(void)
@@ -451,7 +446,7 @@ static void test_BindToObject(void)
hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
IShellFolder_Release(psfDesktop);
- IMalloc_Free(ppM, pidlMyComputer);
+ ILFree(pidlMyComputer);
if (hr != S_OK) return;
hr = IShellFolder_BindToObject(psfMyComputer, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
@@ -478,7 +473,7 @@ static void test_BindToObject(void)
hr = IShellFolder_BindToObject(psfMyComputer, pidlSystemDir, NULL, &IID_IShellFolder, (LPVOID*)&psfSystemDir);
ok (hr == S_OK, "MyComputer failed to bind to a FileSystem ShellFolder! hr = %08x\n", hr);
IShellFolder_Release(psfMyComputer);
- IMalloc_Free(ppM, pidlSystemDir);
+ ILFree(pidlSystemDir);
if (hr != S_OK) return;
hr = IShellFolder_BindToObject(psfSystemDir, pidlEmpty, NULL, &IID_IShellFolder, (LPVOID*)&psfChild);
@@ -860,7 +855,7 @@ static void test_CallForAttributes(void)
if (lResult != ERROR_SUCCESS) {
if (lResult == ERROR_ACCESS_DENIED)
skip("Not enough rights to open the registry key\n");
- IMalloc_Free(ppM, pidlMyDocuments);
+ ILFree(pidlMyDocuments);
IShellFolder_Release(psfDesktop);
return;
}
@@ -871,7 +866,7 @@ static void test_CallForAttributes(void)
ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
if (lResult != ERROR_SUCCESS) {
RegCloseKey(hKey);
- IMalloc_Free(ppM, pidlMyDocuments);
+ ILFree(pidlMyDocuments);
IShellFolder_Release(psfDesktop);
return;
}
@@ -883,7 +878,7 @@ static void test_CallForAttributes(void)
ok (lResult == ERROR_SUCCESS, "RegQueryValueEx failed! result: %08x\n", lResult);
if (lResult != ERROR_SUCCESS) {
RegCloseKey(hKey);
- IMalloc_Free(ppM, pidlMyDocuments);
+ ILFree(pidlMyDocuments);
IShellFolder_Release(psfDesktop);
return;
}
@@ -916,7 +911,7 @@ static void test_CallForAttributes(void)
RegSetValueExW(hKey, wszCallForAttributes, 0, REG_DWORD,
(LPBYTE)&dwOrigCallForAttributes, sizeof(DWORD));
RegCloseKey(hKey);
- IMalloc_Free(ppM, pidlMyDocuments);
+ ILFree(pidlMyDocuments);
IShellFolder_Release(psfDesktop);
}
@@ -978,7 +973,7 @@ static void test_GetAttributesOf(void)
hr = IShellFolder_BindToObject(psfDesktop, pidlMyComputer, NULL, &IID_IShellFolder, (LPVOID*)&psfMyComputer);
ok (hr == S_OK, "Desktop failed to bind to MyComputer object! hr = %08x\n", hr);
IShellFolder_Release(psfDesktop);
- IMalloc_Free(ppM, pidlMyComputer);
+ ILFree(pidlMyComputer);
if (hr != S_OK) return;
hr = IShellFolder_GetAttributesOf(psfMyComputer, 1, &pidlEmpty, &dwFlags);
@@ -1017,7 +1012,7 @@ static void test_GetAttributesOf(void)
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
ok(hr == S_OK, "BindToObject failed %08x\n", hr);
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
/* get relative PIDL */
hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, cTestDirW, NULL, &newPIDL, 0);
@@ -1030,7 +1025,7 @@ static void test_GetAttributesOf(void)
ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for relative PIDL: %08x\n", dwFlags);
/* free memory */
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
/* append testdirectory name to path */
if (cCurrDirA[len-1] == '\\')
@@ -1048,7 +1043,7 @@ static void test_GetAttributesOf(void)
ok ((dwFlags&SFGAO_FOLDER), "Wrong directory attribute for absolute PIDL: %08x\n", dwFlags);
/* free memory */
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
IShellFolder_Release(testIShellFolder);
@@ -1120,7 +1115,7 @@ static void test_SHGetPathFromIDList(void)
return;
}
- IMalloc_Free(ppM, pidlMyComputer);
+ ILFree(pidlMyComputer);
result = SHGetSpecialFolderPathW(NULL, wszFileName, CSIDL_DESKTOPDIRECTORY, FALSE);
ok(result, "SHGetSpecialFolderPathW failed! Last error: %u\n", GetLastError());
@@ -1143,7 +1138,7 @@ static void test_SHGetPathFromIDList(void)
if (hr != S_OK) {
IShellFolder_Release(psfDesktop);
DeleteFileW(wszFileName);
- IMalloc_Free(ppM, pidlTestFile);
+ ILFree(pidlTestFile);
return;
}
@@ -1154,7 +1149,7 @@ static void test_SHGetPathFromIDList(void)
IShellFolder_Release(psfDesktop);
DeleteFileW(wszFileName);
if (hr != S_OK) {
- IMalloc_Free(ppM, pidlTestFile);
+ ILFree(pidlTestFile);
return;
}
StrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH);
@@ -1191,7 +1186,7 @@ static void test_SHGetPathFromIDList(void)
else
win_skip("SHGetPathFromIDListEx not available\n");
- IMalloc_Free(ppM, pidlTestFile);
+ ILFree(pidlTestFile);
/* Test if we can get the path from the start menu "program files" PIDL. */
hr = SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAM_FILES, &pidlPrograms);
@@ -1199,7 +1194,7 @@ static void test_SHGetPathFromIDList(void)
SetLastError(0xdeadbeef);
result = SHGetPathFromIDListW(pidlPrograms, wszPath);
- IMalloc_Free(ppM, pidlPrograms);
+ ILFree(pidlPrograms);
ok(result, "SHGetPathFromIDListW failed\n");
}
@@ -1243,7 +1238,7 @@ static void test_EnumObjects_and_CompareIDs(void)
Cleanup();
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
IShellFolder_Release(IDesktopFolder);
}
@@ -1948,7 +1943,7 @@ static void test_LocalizedNames(void)
hr = IShellFolder_BindToObject(IDesktopFolder, newPIDL, NULL, (REFIID)&IID_IShellFolder, (LPVOID *)&testIShellFolder);
ok(hr == S_OK, "BindToObject failed %08x\n", hr);
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
/* windows reads the display name from the resource */
hr = IShellFolder_ParseDisplayName(testIShellFolder, NULL, NULL, foldernameW, NULL, &newPIDL, 0);
@@ -1982,7 +1977,7 @@ static void test_LocalizedNames(void)
IShellFolder_Release(IDesktopFolder);
IShellFolder_Release(testIShellFolder);
- IMalloc_Free(ppM, newPIDL);
+ ILFree(newPIDL);
cleanup:
DeleteFileA(".\\testfolder\\desktop.ini");
--
2.24.1
More information about the wine-devel
mailing list