[PATCH 1/2] browseui: Use CRT memory allocation functions.
Nikolay Sivov
nsivov at codeweavers.com
Mon Mar 28 06:04:08 CDT 2022
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/browseui/aclmulti.c | 30 ++++++++++-------------
dlls/browseui/aclsource.c | 13 ++--------
dlls/browseui/browseui_main.c | 5 ++--
dlls/browseui/compcatcachedaemon.c | 7 ++----
dlls/browseui/progressdlg.c | 38 ++++++++++--------------------
5 files changed, 31 insertions(+), 62 deletions(-)
diff --git a/dlls/browseui/aclmulti.c b/dlls/browseui/aclmulti.c
index a41cb810369..47547cdd1e1 100644
--- a/dlls/browseui/aclmulti.c
+++ b/dlls/browseui/aclmulti.c
@@ -34,8 +34,6 @@
#include "shlguid.h"
#include "shlobj.h"
-#include "wine/heap.h"
-
#include "browseui.h"
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
@@ -80,17 +78,6 @@ static void release_obj(struct ACLMultiSublist *obj)
IACList_Release(obj->pACL);
}
-static void ACLMulti_Destructor(ACLMulti *This)
-{
- int i;
- TRACE("destroying %p\n", This);
- for (i = 0; i < This->nObjs; i++)
- release_obj(&This->objs[i]);
- heap_free(This->objs);
- heap_free(This);
- BROWSEUI_refCount--;
-}
-
static HRESULT WINAPI ACLMulti_QueryInterface(IEnumString *iface, REFIID iid, LPVOID *ppvOut)
{
ACLMulti *This = impl_from_IEnumString(iface);
@@ -129,10 +116,18 @@ static ULONG WINAPI ACLMulti_Release(IEnumString *iface)
{
ACLMulti *This = impl_from_IEnumString(iface);
ULONG ret;
+ int i;
ret = InterlockedDecrement(&This->refCount);
if (ret == 0)
- ACLMulti_Destructor(This);
+ {
+ for (i = 0; i < This->nObjs; i++)
+ release_obj(&This->objs[i]);
+ free(This->objs);
+ free(This);
+ BROWSEUI_refCount--;
+ }
+
return ret;
}
@@ -224,7 +219,7 @@ static HRESULT WINAPI ACLMulti_Append(IObjMgr *iface, IUnknown *obj)
if (obj == NULL)
return E_FAIL;
- This->objs = heap_realloc(This->objs, sizeof(This->objs[0]) * (This->nObjs+1));
+ This->objs = realloc(This->objs, sizeof(This->objs[0]) * (This->nObjs+1));
This->objs[This->nObjs].punk = obj;
IUnknown_AddRef(obj);
if (FAILED(IUnknown_QueryInterface(obj, &IID_IEnumString, (LPVOID *)&This->objs[This->nObjs].pEnum)))
@@ -247,7 +242,7 @@ static HRESULT WINAPI ACLMulti_Remove(IObjMgr *iface, IUnknown *obj)
release_obj(&This->objs[i]);
memmove(&This->objs[i], &This->objs[i+1], (This->nObjs-i-1)*sizeof(struct ACLMultiSublist));
This->nObjs--;
- This->objs = heap_realloc(This->objs, sizeof(This->objs[0]) * This->nObjs);
+ This->objs = realloc(This->objs, sizeof(This->objs[0]) * This->nObjs);
return S_OK;
}
@@ -313,8 +308,7 @@ HRESULT ACLMulti_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
- This = heap_alloc_zero(sizeof(ACLMulti));
- if (This == NULL)
+ if (!(This = calloc(1, sizeof(ACLMulti))))
return E_OUTOFMEMORY;
This->IEnumString_iface.lpVtbl = &ACLMultiVtbl;
diff --git a/dlls/browseui/aclsource.c b/dlls/browseui/aclsource.c
index 4412ca38003..72bf323c62e 100644
--- a/dlls/browseui/aclsource.c
+++ b/dlls/browseui/aclsource.c
@@ -34,8 +34,6 @@
#include "shlguid.h"
#include "shlobj.h"
-#include "wine/heap.h"
-
#include "browseui.h"
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
@@ -57,12 +55,6 @@ static inline ACLShellSource *impl_from_IEnumString(IEnumString *iface)
return CONTAINING_RECORD(iface, ACLShellSource, IEnumString_iface);
}
-static void ACLShellSource_Destructor(ACLShellSource *This)
-{
- TRACE("destroying %p\n", This);
- heap_free(This);
-}
-
static HRESULT WINAPI ACLShellSource_QueryInterface(IEnumString *iface, REFIID iid, LPVOID *ppvOut)
{
ACLShellSource *This = impl_from_IEnumString(iface);
@@ -106,7 +98,7 @@ static ULONG WINAPI ACLShellSource_Release(IEnumString *iface)
TRACE("(%p)->(%lu)\n", This, ref);
if (ref == 0)
- ACLShellSource_Destructor(This);
+ free(This);
return ref;
}
@@ -205,8 +197,7 @@ HRESULT ACLShellSource_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
- This = heap_alloc_zero(sizeof(ACLShellSource));
- if (This == NULL)
+ if (!(This = calloc(1, sizeof(*This))))
return E_OUTOFMEMORY;
This->IEnumString_iface.lpVtbl = &ACLShellSourceVtbl;
diff --git a/dlls/browseui/browseui_main.c b/dlls/browseui/browseui_main.c
index b6962b30f26..6d089725d3c 100644
--- a/dlls/browseui/browseui_main.c
+++ b/dlls/browseui/browseui_main.c
@@ -32,7 +32,6 @@
#include "shlguid.h"
#include "rpcproxy.h"
-#include "wine/heap.h"
#include "browseui.h"
#include "initguid.h"
@@ -72,7 +71,7 @@ static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
static void ClassFactory_Destructor(ClassFactory *This)
{
TRACE("Destroying class factory %p\n", This);
- heap_free(This);
+ free(This);
InterlockedDecrement(&BROWSEUI_refCount);
}
@@ -147,7 +146,7 @@ static const IClassFactoryVtbl ClassFactoryVtbl = {
static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
{
- ClassFactory *This = heap_alloc(sizeof(ClassFactory));
+ ClassFactory *This = malloc(sizeof(*This));
This->IClassFactory_iface.lpVtbl = &ClassFactoryVtbl;
This->ref = 1;
This->ctor = ctor;
diff --git a/dlls/browseui/compcatcachedaemon.c b/dlls/browseui/compcatcachedaemon.c
index 6de0d87ef38..f7a5e4b449f 100644
--- a/dlls/browseui/compcatcachedaemon.c
+++ b/dlls/browseui/compcatcachedaemon.c
@@ -34,8 +34,6 @@
#include "shlguid.h"
#include "shlobj.h"
-#include "wine/heap.h"
-
#include "browseui.h"
#include "resids.h"
@@ -57,7 +55,7 @@ static void CompCatCacheDaemon_Destructor(CompCatCacheDaemon *This)
TRACE("destroying %p\n", This);
This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs);
- heap_free(This);
+ free(This);
InterlockedDecrement(&BROWSEUI_refCount);
}
@@ -146,8 +144,7 @@ HRESULT CompCatCacheDaemon_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
- This = heap_alloc(sizeof(CompCatCacheDaemon));
- if (This == NULL)
+ if (!(This = calloc(1, sizeof(*This))))
return E_OUTOFMEMORY;
This->IRunnableTask_iface.lpVtbl = &CompCatCacheDaemonVtbl;
diff --git a/dlls/browseui/progressdlg.c b/dlls/browseui/progressdlg.c
index dc0fe813f68..11a973034fa 100644
--- a/dlls/browseui/progressdlg.c
+++ b/dlls/browseui/progressdlg.c
@@ -34,8 +34,6 @@
#include "shlguid.h"
#include "shlobj.h"
-#include "wine/heap.h"
-
#include "browseui.h"
#include "resids.h"
@@ -88,17 +86,8 @@ static inline ProgressDialog *impl_from_IOleWindow(IOleWindow *iface)
static void set_buffer(LPWSTR *buffer, LPCWSTR string)
{
- IMalloc *malloc;
- ULONG cb;
-
- if (string == NULL)
- string = L"";
- CoGetMalloc(MEMCTX_TASK, &malloc);
-
- cb = (lstrlenW(string) + 1)*sizeof(WCHAR);
- if (*buffer == NULL || cb > IMalloc_GetSize(malloc, *buffer))
- *buffer = IMalloc_Realloc(malloc, *buffer, cb);
- memcpy(*buffer, string, cb);
+ free(*buffer);
+ *buffer = wcsdup(string ? string : L"");
}
struct create_params
@@ -114,7 +103,7 @@ static LPWSTR load_string(HINSTANCE hInstance, UINT uiResourceId)
LPWSTR ret;
LoadStringW(hInstance, uiResourceId, string, ARRAY_SIZE(string));
- ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(string) + 1) * sizeof(WCHAR));
+ ret = malloc((lstrlenW(string) + 1) * sizeof(WCHAR));
lstrcpyW(ret, string);
return ret;
}
@@ -277,17 +266,17 @@ static void ProgressDialog_Destructor(ProgressDialog *This)
TRACE("destroying %p\n", This);
if (This->hwnd)
end_dialog(This);
- for (i = 0; i < 3; i++)
- heap_free(This->lines[i]);
- heap_free(This->cancelMsg);
- heap_free(This->title);
- for (i = 0; i < 2; i++)
- heap_free(This->remainingMsg[i]);
- for (i = 0; i < 3; i++)
- heap_free(This->timeMsg[i]);
+ for (i = 0; i < ARRAY_SIZE(This->lines); i++)
+ free(This->lines[i]);
+ free(This->cancelMsg);
+ free(This->title);
+ for (i = 0; i < ARRAY_SIZE(This->remainingMsg); i++)
+ free(This->remainingMsg[i]);
+ for (i = 0; i < ARRAY_SIZE(This->timeMsg); i++)
+ free(This->timeMsg[i]);
This->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->cs);
- heap_free(This);
+ free(This);
InterlockedDecrement(&BROWSEUI_refCount);
}
@@ -635,8 +624,7 @@ HRESULT ProgressDialog_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
if (pUnkOuter)
return CLASS_E_NOAGGREGATION;
- This = heap_alloc_zero(sizeof(ProgressDialog));
- if (This == NULL)
+ if (!(This = calloc(1, sizeof(*This))))
return E_OUTOFMEMORY;
This->IProgressDialog_iface.lpVtbl = &ProgressDialogVtbl;
--
2.35.1
More information about the wine-devel
mailing list