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

View File

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

View File

@ -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
*/

View File

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

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 */
} 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;
}