[PATCH] shell32/tests: Use CRT memory allocation functions.

Nikolay Sivov nsivov at codeweavers.com
Tue Apr 5 10:09:07 CDT 2022


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/shell32/tests/assoc.c         |  7 +++----
 dlls/shell32/tests/autocomplete.c  |  5 ++---
 dlls/shell32/tests/ebrowser.c      | 13 ++++++-------
 dlls/shell32/tests/msg.h           |  9 ++++-----
 dlls/shell32/tests/shelldispatch.c |  5 ++---
 dlls/shell32/tests/shelllink.c     |  5 ++---
 dlls/shell32/tests/shlexec.c       |  9 ++++-----
 dlls/shell32/tests/shlfolder.c     | 21 ++++++++++-----------
 dlls/shell32/tests/shlview.c       |  9 ++++-----
 9 files changed, 37 insertions(+), 46 deletions(-)

diff --git a/dlls/shell32/tests/assoc.c b/dlls/shell32/tests/assoc.c
index 403390d8a09..0e28d9f0355 100644
--- a/dlls/shell32/tests/assoc.c
+++ b/dlls/shell32/tests/assoc.c
@@ -25,7 +25,6 @@
 #include "shlguid.h"
 #include "shobjidl.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 
@@ -104,8 +103,8 @@ static struct assoc_getstring_test getstring_tests[] =
 static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCWSTR expected_string, int line)
 {
     IQueryAssociations *assoc;
+    WCHAR *buffer;
     HRESULT hr;
-    WCHAR *buffer = NULL;
     DWORD len;
 
     hr = CoCreateInstance(&CLSID_QueryAssociations, NULL, CLSCTX_INPROC_SERVER, &IID_IQueryAssociations, (void*)&assoc);
@@ -122,19 +121,19 @@ static void getstring_test(LPCWSTR assocName, HKEY progIdKey, ASSOCSTR str, LPCW
             return;
         }
 
-        buffer = heap_alloc(len * sizeof(WCHAR));
+        buffer = malloc(len * sizeof(WCHAR));
         ok_(__FILE__, line)(buffer != NULL, "out of memory\n");
         hr = IQueryAssociations_GetString(assoc, 0, str, NULL, buffer, &len);
         ok_(__FILE__, line)(hr == S_OK, "GetString returned 0x%lx, expected S_OK\n", hr);
 
         ok_(__FILE__, line)(lstrcmpW(buffer, expected_string) == 0, "GetString returned %s, expected %s\n",
                 wine_dbgstr_w(buffer), wine_dbgstr_w(expected_string));
+        free(buffer);
     } else {
         ok_(__FILE__, line)(FAILED(hr), "GetString returned 0x%lx, expected failure\n", hr);
     }
 
     IQueryAssociations_Release(assoc);
-    heap_free(buffer);
 }
 
 static void test_IQueryAssociations_GetString(void)
diff --git a/dlls/shell32/tests/autocomplete.c b/dlls/shell32/tests/autocomplete.c
index 0631126c021..d0df5b225c1 100644
--- a/dlls/shell32/tests/autocomplete.c
+++ b/dlls/shell32/tests/autocomplete.c
@@ -28,7 +28,6 @@
 #include "shldisp.h"
 #include "shlobj.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 static HWND hMainWnd, hEdit;
@@ -317,7 +316,7 @@ static ULONG WINAPI string_enumerator_Release(IEnumString *iface)
     ULONG ref = InterlockedDecrement(&this->ref);
 
     if (!ref)
-        heap_free(this);
+        free(this);
 
     return ref;
 }
@@ -426,7 +425,7 @@ static HRESULT string_enumerator_create(void **ppv, WCHAR **suggestions, int cou
 {
     struct string_enumerator *object;
 
-    object = heap_alloc_zero(sizeof(*object));
+    object = calloc(1, sizeof(*object));
     object->IEnumString_iface.lpVtbl = &string_enumerator_vtbl;
     object->IACList_iface.lpVtbl = &aclist_vtbl;
     object->ref = 1;
diff --git a/dlls/shell32/tests/ebrowser.c b/dlls/shell32/tests/ebrowser.c
index 257084053a7..9402388f643 100644
--- a/dlls/shell32/tests/ebrowser.c
+++ b/dlls/shell32/tests/ebrowser.c
@@ -26,7 +26,6 @@
 #include "shlobj.h"
 #include "shlwapi.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include "initguid.h"
@@ -193,7 +192,7 @@ static ULONG WINAPI IExplorerPaneVisibility_fnRelease(IExplorerPaneVisibility *i
     ULONG ref = InterlockedDecrement(&This->ref);
 
     if(!ref)
-        heap_free(This);
+        free(This);
 
     return ref;
 }
@@ -239,7 +238,7 @@ static IExplorerPaneVisibilityImpl *create_explorerpanevisibility(void)
 {
     IExplorerPaneVisibilityImpl *epv;
 
-    epv = heap_alloc_zero(sizeof(*epv));
+    epv = calloc(1, sizeof(*epv));
     epv->IExplorerPaneVisibility_iface.lpVtbl = &epvvt;
     epv->ref = 1;
 
@@ -282,7 +281,7 @@ static ULONG WINAPI ICommDlgBrowser3_fnRelease(ICommDlgBrowser3 *iface)
     ULONG ref = InterlockedDecrement(&This->ref);
 
     if(!ref)
-        heap_free(This);
+        free(This);
 
     return ref;
 }
@@ -393,7 +392,7 @@ static ICommDlgBrowser3Impl *create_commdlgbrowser3(void)
 {
     ICommDlgBrowser3Impl *cdb;
 
-    cdb = heap_alloc_zero(sizeof(*cdb));
+    cdb = calloc(1, sizeof(*cdb));
     cdb->ICommDlgBrowser3_iface.lpVtbl = &cdbvtbl;
     cdb->ref = 1;
 
@@ -450,7 +449,7 @@ static ULONG WINAPI IServiceProvider_fnRelease(IServiceProvider *iface)
     LONG ref = InterlockedDecrement(&This->ref);
 
     if(!ref)
-        heap_free(This);
+        free(This);
 
     return ref;
 }
@@ -491,7 +490,7 @@ static const IServiceProviderVtbl spvtbl =
 
 static IServiceProviderImpl *create_serviceprovider(void)
 {
-    IServiceProviderImpl *sp = heap_alloc(sizeof(*sp));
+    IServiceProviderImpl *sp = malloc(sizeof(*sp));
     sp->IServiceProvider_iface.lpVtbl = &spvtbl;
     sp->ref = 1;
     return sp;
diff --git a/dlls/shell32/tests/msg.h b/dlls/shell32/tests/msg.h
index a6c16ae05e6..a2b723cfb89 100644
--- a/dlls/shell32/tests/msg.h
+++ b/dlls/shell32/tests/msg.h
@@ -21,7 +21,6 @@
 #include <assert.h>
 #include <windows.h>
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 /* undocumented SWP flags - from SDK 3.1 */
@@ -68,13 +67,13 @@ static void add_message(struct msg_sequence **seq, int sequence_index,
     if (!msg_seq->sequence)
     {
         msg_seq->size = 10;
-        msg_seq->sequence = heap_alloc(msg_seq->size * sizeof (struct message));
+        msg_seq->sequence = malloc(msg_seq->size * sizeof (struct message));
     }
 
     if (msg_seq->count == msg_seq->size)
     {
         msg_seq->size *= 2;
-        msg_seq->sequence = heap_realloc(msg_seq->sequence, msg_seq->size * sizeof (struct message));
+        msg_seq->sequence = realloc(msg_seq->sequence, msg_seq->size * sizeof (struct message));
     }
 
     assert(msg_seq->sequence);
@@ -91,7 +90,7 @@ static void add_message(struct msg_sequence **seq, int sequence_index,
 static void flush_sequence(struct msg_sequence **seg, int sequence_index)
 {
     struct msg_sequence *msg_seq = seg[sequence_index];
-    heap_free(msg_seq->sequence);
+    free(msg_seq->sequence);
     msg_seq->sequence = NULL;
     msg_seq->count = msg_seq->size = 0;
 }
@@ -289,5 +288,5 @@ static void init_msg_sequences(struct msg_sequence **seq, int n)
     int i;
 
     for (i = 0; i < n; i++)
-        seq[i] = heap_alloc_zero(sizeof(struct msg_sequence));
+        seq[i] = calloc(1, sizeof(struct msg_sequence));
 }
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index 3894f67dd11..67659f72345 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -27,7 +27,6 @@
 #include "shlwapi.h"
 #include "winsvc.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include "initguid.h"
@@ -278,7 +277,7 @@ static void test_namespace(void)
     GetFullPathNameW(winetestW, MAX_PATH, tempW, NULL);
 
     len = GetLongPathNameW(tempW, NULL, 0);
-    long_pathW = heap_alloc(len * sizeof(WCHAR));
+    long_pathW = malloc(len * sizeof(WCHAR));
     GetLongPathNameW(tempW, long_pathW, len);
 
     V_VT(&var) = VT_BSTR;
@@ -350,7 +349,7 @@ static void test_namespace(void)
         SysFreeString(V_BSTR(&var));
     }
 
-    heap_free(long_pathW);
+    free(long_pathW);
     RemoveDirectoryW(winetestW);
     SetCurrentDirectoryW(curW);
     IShellDispatch_Release(sd);
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index e4e1e664038..8cbc46696ab 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -29,7 +29,6 @@
 #include "shellapi.h"
 #include "commoncontrols.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include "shell32_test.h"
@@ -70,12 +69,12 @@ static LPITEMIDLIST path_to_pidl(const char* path)
         int len;
 
         len=MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
-        pathW = heap_alloc(len * sizeof(WCHAR));
+        pathW = malloc(len * sizeof(WCHAR));
         MultiByteToWideChar(CP_ACP, 0, path, -1, pathW, len);
 
         r=pSHILCreateFromPath(pathW, &pidl, NULL);
         ok(r == S_OK, "SHILCreateFromPath failed (0x%08lx)\n", r);
-        heap_free(pathW);
+        free(pathW);
     }
     return pidl;
 }
diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c
index cea7245f387..50c2e84578b 100644
--- a/dlls/shell32/tests/shlexec.c
+++ b/dlls/shell32/tests/shlexec.c
@@ -40,7 +40,6 @@
 #include "shlwapi.h"
 #include "ddeml.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include "shell32_test.h"
@@ -756,7 +755,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
     if (dwMaxLen > ARRAY_SIZE(szNameBuf))
     {
         /* Name too big: alloc a buffer for it */
-        if (!(lpszName = heap_alloc(dwMaxLen*sizeof(CHAR))))
+        if (!(lpszName = malloc(dwMaxLen*sizeof(CHAR))))
         {
             ret = ERROR_NOT_ENOUGH_MEMORY;
             goto cleanup;
@@ -791,7 +790,7 @@ static LSTATUS myRegDeleteTreeA(HKEY hKey, LPCSTR lpszSubKey)
 cleanup:
     /* Free buffer if allocated */
     if (lpszName != szNameBuf)
-        heap_free(lpszName);
+        free(lpszName);
     if(lpszSubKey)
         RegCloseKey(hSubKey);
     return ret;
@@ -851,11 +850,11 @@ static void create_test_verb_dde(const char* classname, const char* verb,
     }
     else
     {
-        cmd = heap_alloc(strlen(argv0) + 10 + strlen(child_file) + 2 + strlen(cmdtail) + 1);
+        cmd = malloc(strlen(argv0) + 10 + strlen(child_file) + 2 + strlen(cmdtail) + 1);
         sprintf(cmd,"%s shlexec \"%s\" %s", argv0, child_file, cmdtail);
         rc=RegSetValueExA(hkey_cmd, NULL, 0, REG_SZ, (LPBYTE)cmd, strlen(cmd)+1);
         ok(rc == ERROR_SUCCESS, "setting command failed with %ld\n", rc);
-        heap_free(cmd);
+        free(cmd);
     }
 
     if (ddeexec)
diff --git a/dlls/shell32/tests/shlfolder.c b/dlls/shell32/tests/shlfolder.c
index 7b81ef98110..f99045c33d5 100644
--- a/dlls/shell32/tests/shlfolder.c
+++ b/dlls/shell32/tests/shlfolder.c
@@ -37,7 +37,6 @@
 #include "ocidl.h"
 #include "oleauto.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include <initguid.h>
@@ -75,7 +74,7 @@ static WCHAR *make_wstr(const char *str)
     if(!len || len < 0)
         return NULL;
 
-    ret = heap_alloc(len * sizeof(WCHAR));
+    ret = malloc(len * sizeof(WCHAR));
     if(!ret)
         return NULL;
 
@@ -3032,7 +3031,7 @@ static void test_SHGetIDListFromObject(void)
     hres = pSHGetIDListFromObject(NULL, &pidl);
     ok(hres == E_NOINTERFACE, "Got %lx\n", hres);
 
-    punkimpl = heap_alloc(sizeof(*punkimpl));
+    punkimpl = malloc(sizeof(*punkimpl));
     punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown;
     punkimpl->ifaces = ifaces;
     punkimpl->unknown = 0;
@@ -3049,7 +3048,7 @@ static void test_SHGetIDListFromObject(void)
        "interface not requested.\n");
 
     ok(!punkimpl->unknown, "Got %ld unknown.\n", punkimpl->unknown);
-    heap_free(punkimpl);
+    free(punkimpl);
 
     pidl_desktop = NULL;
     SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl_desktop);
@@ -3203,7 +3202,7 @@ static void test_SHGetItemFromObject(void)
     hres = pSHGetItemFromObject(NULL, &IID_IUnknown, (void**)&punk);
     ok(hres == E_NOINTERFACE, "Got 0x%08lx\n", hres);
 
-    punkimpl = heap_alloc(sizeof(*punkimpl));
+    punkimpl = malloc(sizeof(*punkimpl));
     punkimpl->IUnknown_iface.lpVtbl = &vt_IUnknown;
     punkimpl->ifaces = ifaces;
     punkimpl->unknown = 0;
@@ -3221,7 +3220,7 @@ static void test_SHGetItemFromObject(void)
        "interface not requested.\n");
 
     ok(!punkimpl->unknown, "Got %ld unknown.\n", punkimpl->unknown);
-    heap_free(punkimpl);
+    free(punkimpl);
 
     /* Test IShellItem */
     hres = pSHGetItemFromObject((IUnknown*)psfdesktop, &IID_IShellItem, (void**)&psi);
@@ -4584,7 +4583,7 @@ static void r_verify_pidl(unsigned l, LPCITEMIDLIST pidl, const WCHAR *path)
             WCHAR *strW = make_wstr(U(filename).cStr);
             ok_(__FILE__,l)(!lstrcmpW(path, strW), "didn't get expected path (%s), instead: %s\n",
                      wine_dbgstr_w(path), U(filename).cStr);
-            heap_free(strW);
+            free(strW);
         }
 
         IShellFolder_Release(parent);
@@ -4918,8 +4917,8 @@ static LRESULT CALLBACK testwindow_wndproc(HWND hwnd, UINT msg, WPARAM wparam, L
             path2 = make_wstr(exp_data->path_2);
             verify_pidl(pidls[0], path1);
             verify_pidl(pidls[1], path2);
-            heap_free(path1);
-            heap_free(path2);
+            free(path1);
+            free(path2);
 
             exp_data->missing_events--;
 
@@ -5027,8 +5026,8 @@ static void test_SHChangeNotify(BOOL test_new_delivery)
             do_events();
             ok(exp_data->missing_events == 0, "%s: Expected wndproc to be called\n", exp_data->id);
 
-            heap_free(path1);
-            heap_free(path2);
+            free(path1);
+            free(path2);
         }
     }
 
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index b405a84bc19..a83f3137509 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -38,7 +38,6 @@
 
 #include "initguid.h"
 
-#include "wine/heap.h"
 #include "wine/test.h"
 
 #include "msg.h"
@@ -150,7 +149,7 @@ static IDataObject* IDataObjectImpl_Construct(void)
 {
     IDataObjectImpl *obj;
 
-    obj = heap_alloc(sizeof(*obj));
+    obj = malloc(sizeof(*obj));
     obj->IDataObject_iface.lpVtbl = &IDataObjectImpl_Vtbl;
     obj->ref = 1;
 
@@ -188,7 +187,7 @@ static ULONG WINAPI IDataObjectImpl_Release(IDataObject * iface)
     ULONG ref = InterlockedDecrement(&This->ref);
 
     if (!ref)
-        heap_free(This);
+        free(This);
 
     return ref;
 }
@@ -275,7 +274,7 @@ static IShellBrowser* IShellBrowserImpl_Construct(void)
 {
     IShellBrowserImpl *browser;
 
-    browser = heap_alloc(sizeof(*browser));
+    browser = malloc(sizeof(*browser));
     browser->IShellBrowser_iface.lpVtbl = &IShellBrowserImpl_Vtbl;
     browser->ref = 1;
 
@@ -318,7 +317,7 @@ static ULONG WINAPI IShellBrowserImpl_Release(IShellBrowser * iface)
     ULONG ref = InterlockedDecrement(&This->ref);
 
     if (!ref)
-        heap_free(This);
+        free(This);
 
     return ref;
 }
-- 
2.35.1




More information about the wine-devel mailing list