From 448a44ca5f586400ee1bda3e104df516f985441a Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 19 Apr 2013 13:38:13 +0400 Subject: [PATCH] ole32: Simplify IEnumSTATSTG initialization. --- dlls/ole32/storage32.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index d3e351b596b..425fd125d0b 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -732,9 +732,6 @@ static HRESULT WINAPI StorageBaseImpl_EnumElements( if (newEnum) { *ppenum = &newEnum->IEnumSTATSTG_iface; - - IEnumSTATSTG_AddRef(*ppenum); - return S_OK; } @@ -5599,36 +5596,30 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Clone( IEnumSTATSTG** ppenum) { IEnumSTATSTGImpl* const This = impl_from_IEnumSTATSTG(iface); - IEnumSTATSTGImpl* newClone; if (This->parentStorage->reverted) return STG_E_REVERTED; - /* - * Perform a sanity check on the parameters. - */ if (ppenum==0) return E_INVALIDARG; newClone = IEnumSTATSTGImpl_Construct(This->parentStorage, This->storageDirEntry); - + if (!newClone) + { + *ppenum = NULL; + return E_OUTOFMEMORY; + } /* * The new clone enumeration must point to the same current node as - * the ole one. + * the old one. */ memcpy(newClone->name, This->name, sizeof(newClone->name)); *ppenum = &newClone->IEnumSTATSTG_iface; - /* - * Don't forget to nail down a reference to the clone before - * returning it. - */ - IEnumSTATSTGImpl_AddRef(*ppenum); - return S_OK; } @@ -5658,13 +5649,11 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct( newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl)); - if (newEnumeration!=0) + if (newEnumeration) { - /* - * Set-up the virtual function table and reference count. - */ newEnumeration->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTGImpl_Vtbl; - newEnumeration->ref = 0; + newEnumeration->ref = 1; + newEnumeration->name[0] = 0; /* * We want to nail-down the reference to the storage in case the @@ -5673,12 +5662,7 @@ static IEnumSTATSTGImpl* IEnumSTATSTGImpl_Construct( newEnumeration->parentStorage = parentStorage; IStorage_AddRef(&newEnumeration->parentStorage->IStorage_iface); - newEnumeration->storageDirEntry = storageDirEntry; - - /* - * Make sure the current node of the iterator is the first one. - */ - IEnumSTATSTGImpl_Reset(&newEnumeration->IEnumSTATSTG_iface); + newEnumeration->storageDirEntry = storageDirEntry; } return newEnumeration;