browseui: Code clean up.

This commit is contained in:
Jacek Caban 2008-02-22 02:22:59 +01:00 committed by Alexandre Julliard
parent be1e2080b3
commit 04ba306690
5 changed files with 68 additions and 68 deletions

View File

@ -310,10 +310,10 @@ HRESULT ACLMulti_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
if (pUnkOuter) if (pUnkOuter)
return CLASS_E_NOAGGREGATION; return CLASS_E_NOAGGREGATION;
This = heap_alloc(sizeof(ACLMulti)); This = heap_alloc_zero(sizeof(ACLMulti));
if (This == NULL) if (This == NULL)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
ZeroMemory(This, sizeof(*This));
This->vtbl = &ACLMultiVtbl; This->vtbl = &ACLMultiVtbl;
This->aclVtbl = &ACLMulti_ACListVtbl; This->aclVtbl = &ACLMulti_ACListVtbl;
This->objmgrVtbl = &ACLMulti_ObjMgrVtbl; This->objmgrVtbl = &ACLMulti_ObjMgrVtbl;

View File

@ -35,6 +35,11 @@ static inline void *heap_alloc(size_t size)
return HeapAlloc(GetProcessHeap(), 0, 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) static inline void *heap_realloc(void *mem, size_t size)
{ {
return mem ? HeapReAlloc(GetProcessHeap(), 0, mem, size) : heap_alloc(size); return mem ? HeapReAlloc(GetProcessHeap(), 0, mem, size) : heap_alloc(size);

View File

@ -64,24 +64,11 @@ typedef struct tagClassFactory
LONG ref; LONG ref;
LPFNCONSTRUCTOR ctor; LPFNCONSTRUCTOR ctor;
} ClassFactory; } 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) static void ClassFactory_Destructor(ClassFactory *This)
{ {
TRACE("Destroying class factory %p\n", This); TRACE("Destroying class factory %p\n", This);
CoTaskMemFree(This); heap_free(This);
BROWSEUI_refCount--; BROWSEUI_refCount--;
} }
@ -154,6 +141,18 @@ static const IClassFactoryVtbl ClassFactoryVtbl = {
ClassFactory_LockServer 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 * BROWSEUI DllMain
*/ */

View File

@ -49,33 +49,11 @@ typedef struct tagCCCD {
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
} CompCatCacheDaemon; } 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) static void CompCatCacheDaemon_Destructor(CompCatCacheDaemon *This)
{ {
TRACE("destroying %p\n", This); TRACE("destroying %p\n", This);
DeleteCriticalSection(&This->cs); DeleteCriticalSection(&This->cs);
CoTaskMemFree(This); heap_free(This);
BROWSEUI_refCount--; BROWSEUI_refCount--;
} }
@ -157,3 +135,23 @@ static const IRunnableTaskVtbl CompCatCacheDaemonVtbl =
CompCatCacheDaemon_Resume, CompCatCacheDaemon_Resume,
CompCatCacheDaemon_IsRunning 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;
}

View File

@ -74,8 +74,6 @@ typedef struct tagProgressDialog {
HWND hwndDisabledParent; /* For modal dialog: the parent that need to be re-enabled when the dialog ends */ HWND hwndDisabledParent; /* For modal dialog: the parent that need to be re-enabled when the dialog ends */
} ProgressDialog; } ProgressDialog;
static const IProgressDialogVtbl ProgressDialogVtbl;
static void set_buffer(LPWSTR *buffer, LPCWSTR string) static void set_buffer(LPWSTR *buffer, LPCWSTR string)
{ {
static const WCHAR empty_string[] = {0}; static const WCHAR empty_string[] = {0};
@ -246,37 +244,17 @@ static DWORD WINAPI dialog_thread(LPVOID lpParameter)
return 0; return 0;
} }
HRESULT ProgressDialog_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut) static void ProgressDialog_Destructor(ProgressDialog *This)
{
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)
{ {
TRACE("destroying %p\n", This); TRACE("destroying %p\n", This);
if (This->hwnd) if (This->hwnd)
end_dialog(This); end_dialog(This);
CoTaskMemFree(This->lines[0]); heap_free(This->lines[0]);
CoTaskMemFree(This->lines[1]); heap_free(This->lines[1]);
CoTaskMemFree(This->lines[2]); heap_free(This->lines[2]);
CoTaskMemFree(This->cancelMsg); heap_free(This->cancelMsg);
CoTaskMemFree(This->title); heap_free(This->title);
CoTaskMemFree(This); heap_free(This);
BROWSEUI_refCount--; BROWSEUI_refCount--;
} }
@ -504,3 +482,23 @@ static const IProgressDialogVtbl ProgressDialogVtbl =
ProgressDialog_SetCancelMsg, ProgressDialog_SetCancelMsg,
ProgressDialog_Timer 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;
}