diff --git a/dlls/browseui/aclmulti.c b/dlls/browseui/aclmulti.c index 95ede34ddcc..c7daba065ae 100644 --- a/dlls/browseui/aclmulti.c +++ b/dlls/browseui/aclmulti.c @@ -310,10 +310,10 @@ HRESULT ACLMulti_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) if (pUnkOuter) return CLASS_E_NOAGGREGATION; - This = heap_alloc(sizeof(ACLMulti)); + This = heap_alloc_zero(sizeof(ACLMulti)); if (This == NULL) return E_OUTOFMEMORY; - ZeroMemory(This, sizeof(*This)); + This->vtbl = &ACLMultiVtbl; This->aclVtbl = &ACLMulti_ACListVtbl; This->objmgrVtbl = &ACLMulti_ObjMgrVtbl; diff --git a/dlls/browseui/browseui.h b/dlls/browseui/browseui.h index 0b620090f9c..28086470a48 100644 --- a/dlls/browseui/browseui.h +++ b/dlls/browseui/browseui.h @@ -35,6 +35,11 @@ static inline void *heap_alloc(size_t size) return HeapAlloc(GetProcessHeap(), 0, size); } +static inline void *heap_alloc_zero(size_t size) +{ + return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); +} + static inline void *heap_realloc(void *mem, size_t size) { return mem ? HeapReAlloc(GetProcessHeap(), 0, mem, size) : heap_alloc(size); diff --git a/dlls/browseui/browseui_main.c b/dlls/browseui/browseui_main.c index c370408c025..dda6c3c8eae 100644 --- a/dlls/browseui/browseui_main.c +++ b/dlls/browseui/browseui_main.c @@ -64,24 +64,11 @@ typedef struct tagClassFactory LONG ref; LPFNCONSTRUCTOR ctor; } ClassFactory; -static const IClassFactoryVtbl ClassFactoryVtbl; - -static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut) -{ - ClassFactory *This = CoTaskMemAlloc(sizeof(ClassFactory)); - This->vtbl = &ClassFactoryVtbl; - This->ref = 1; - This->ctor = ctor; - *ppvOut = (LPVOID)This; - TRACE("Created class factory %p\n", This); - BROWSEUI_refCount++; - return S_OK; -} static void ClassFactory_Destructor(ClassFactory *This) { TRACE("Destroying class factory %p\n", This); - CoTaskMemFree(This); + heap_free(This); BROWSEUI_refCount--; } @@ -154,6 +141,18 @@ static const IClassFactoryVtbl ClassFactoryVtbl = { ClassFactory_LockServer }; +static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut) +{ + ClassFactory *This = heap_alloc(sizeof(ClassFactory)); + This->vtbl = &ClassFactoryVtbl; + This->ref = 1; + This->ctor = ctor; + *ppvOut = (LPVOID)This; + TRACE("Created class factory %p\n", This); + BROWSEUI_refCount++; + return S_OK; +} + /************************************************************************* * BROWSEUI DllMain */ diff --git a/dlls/browseui/compcatcachedaemon.c b/dlls/browseui/compcatcachedaemon.c index f4fd5e64ebf..2cf15e476b7 100644 --- a/dlls/browseui/compcatcachedaemon.c +++ b/dlls/browseui/compcatcachedaemon.c @@ -49,33 +49,11 @@ typedef struct tagCCCD { CRITICAL_SECTION cs; } CompCatCacheDaemon; -static const IRunnableTaskVtbl CompCatCacheDaemonVtbl; - -HRESULT CompCatCacheDaemon_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) -{ - CompCatCacheDaemon *This; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - This = CoTaskMemAlloc(sizeof(CompCatCacheDaemon)); - if (This == NULL) - return E_OUTOFMEMORY; - ZeroMemory(This, sizeof(*This)); - This->vtbl = &CompCatCacheDaemonVtbl; - This->refCount = 1; - InitializeCriticalSection(&This->cs); - - TRACE("returning %p\n", This); - *ppOut = (IUnknown *)This; - BROWSEUI_refCount++; - return S_OK; -} - static void CompCatCacheDaemon_Destructor(CompCatCacheDaemon *This) { TRACE("destroying %p\n", This); DeleteCriticalSection(&This->cs); - CoTaskMemFree(This); + heap_free(This); BROWSEUI_refCount--; } @@ -157,3 +135,23 @@ static const IRunnableTaskVtbl CompCatCacheDaemonVtbl = CompCatCacheDaemon_Resume, CompCatCacheDaemon_IsRunning }; + +HRESULT CompCatCacheDaemon_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) +{ + CompCatCacheDaemon *This; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + This = heap_alloc(sizeof(CompCatCacheDaemon)); + if (This == NULL) + return E_OUTOFMEMORY; + + This->vtbl = &CompCatCacheDaemonVtbl; + This->refCount = 1; + InitializeCriticalSection(&This->cs); + + TRACE("returning %p\n", This); + *ppOut = (IUnknown *)This; + BROWSEUI_refCount++; + return S_OK; +} diff --git a/dlls/browseui/progressdlg.c b/dlls/browseui/progressdlg.c index a0444fd69b9..c5465a35190 100644 --- a/dlls/browseui/progressdlg.c +++ b/dlls/browseui/progressdlg.c @@ -74,8 +74,6 @@ typedef struct tagProgressDialog { HWND hwndDisabledParent; /* For modal dialog: the parent that need to be re-enabled when the dialog ends */ } ProgressDialog; -static const IProgressDialogVtbl ProgressDialogVtbl; - static void set_buffer(LPWSTR *buffer, LPCWSTR string) { static const WCHAR empty_string[] = {0}; @@ -246,37 +244,17 @@ static DWORD WINAPI dialog_thread(LPVOID lpParameter) return 0; } -HRESULT ProgressDialog_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) -{ - ProgressDialog *This; - if (pUnkOuter) - return CLASS_E_NOAGGREGATION; - - This = CoTaskMemAlloc(sizeof(ProgressDialog)); - if (This == NULL) - return E_OUTOFMEMORY; - ZeroMemory(This, sizeof(*This)); - This->vtbl = &ProgressDialogVtbl; - This->refCount = 1; - InitializeCriticalSection(&This->cs); - - TRACE("returning %p\n", This); - *ppOut = (IUnknown *)This; - BROWSEUI_refCount++; - return S_OK; -} - -static void WINAPI ProgressDialog_Destructor(ProgressDialog *This) +static void ProgressDialog_Destructor(ProgressDialog *This) { TRACE("destroying %p\n", This); if (This->hwnd) end_dialog(This); - CoTaskMemFree(This->lines[0]); - CoTaskMemFree(This->lines[1]); - CoTaskMemFree(This->lines[2]); - CoTaskMemFree(This->cancelMsg); - CoTaskMemFree(This->title); - CoTaskMemFree(This); + heap_free(This->lines[0]); + heap_free(This->lines[1]); + heap_free(This->lines[2]); + heap_free(This->cancelMsg); + heap_free(This->title); + heap_free(This); BROWSEUI_refCount--; } @@ -504,3 +482,23 @@ static const IProgressDialogVtbl ProgressDialogVtbl = ProgressDialog_SetCancelMsg, ProgressDialog_Timer }; + +HRESULT ProgressDialog_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) +{ + ProgressDialog *This; + if (pUnkOuter) + return CLASS_E_NOAGGREGATION; + + This = heap_alloc_zero(sizeof(ProgressDialog)); + if (This == NULL) + return E_OUTOFMEMORY; + + This->vtbl = &ProgressDialogVtbl; + This->refCount = 1; + InitializeCriticalSection(&This->cs); + + TRACE("returning %p\n", This); + *ppOut = (IUnknown *)This; + BROWSEUI_refCount++; + return S_OK; +}