browseui: Use CRT memory allocation functions.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-03-28 14:04:08 +03:00 committed by Alexandre Julliard
parent 4d122a26e5
commit 6b5a5c6402
5 changed files with 31 additions and 62 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;