Module: wine Branch: master Commit: 13b9666443cae8a5f6ece8498d1560c67dc66925 URL: http://source.winehq.org/git/wine.git/?a=commit;h=13b9666443cae8a5f6ece8498d...
Author: Vincent Povirk vincent@codeweavers.com Date: Wed Oct 28 14:24:18 2009 -0500
ole32: Convert adjustPropertyChain into real binary tree removal.
Finding the parent of a node in a binary tree is a detail that should be handled inside the function.
---
dlls/ole32/storage32.c | 57 ++++++++++++++++++++++------------------------- 1 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 18ced72..b793b85 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -169,12 +169,10 @@ static HRESULT deleteStreamProperty( ULONG foundPropertyIndexToDelete, StgProperty propertyToDelete);
-static HRESULT adjustPropertyChain( +static HRESULT removeFromTree( StorageImpl *This, - StgProperty propertyToDelete, - StgProperty parentProperty, - ULONG parentPropertyId, - INT typeOfRelation); + ULONG parentStorageIndex, + ULONG deletedIndex);
/*********************************************************************** * Declaration of the functions used to manipulate StgProperty @@ -1755,10 +1753,7 @@ static HRESULT WINAPI StorageImpl_DestroyElement(
HRESULT hr = S_OK; StgProperty propertyToDelete; - StgProperty parentProperty; ULONG foundPropertyIndexToDelete; - ULONG typeOfRelation; - ULONG parentPropertyId = 0;
TRACE("(%p, %s)\n", iface, debugstr_w(pwcsName)); @@ -1780,15 +1775,6 @@ static HRESULT WINAPI StorageImpl_DestroyElement( return STG_E_FILENOTFOUND; }
- /* - * Find the property that links to the one we want to delete. - */ - hr = findTreeParent(This->base.ancestorStorage, This->base.rootPropertySetIndex, - pwcsName, &parentProperty, &parentPropertyId, &typeOfRelation); - - if (hr != S_OK) - return hr; - if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) { hr = deleteStorageProperty( @@ -1810,12 +1796,10 @@ static HRESULT WINAPI StorageImpl_DestroyElement( /* * Adjust the property chain */ - hr = adjustPropertyChain( - This, - propertyToDelete, - parentProperty, - parentPropertyId, - typeOfRelation); + hr = removeFromTree( + This->base.ancestorStorage, + This->base.rootPropertySetIndex, + foundPropertyIndexToDelete);
/* * Invalidate the property by zeroing its name member. @@ -2018,18 +2002,31 @@ static void setPropertyLink(StgProperty *property, ULONG relation, ULONG new_tar * * Internal Method * - * This method takes the previous and the next property link of a property - * to be deleted and find them a place in the Storage. + * This method removes a directory entry from its parent storage tree without + * freeing any resources attached to it. */ -static HRESULT adjustPropertyChain( +static HRESULT removeFromTree( StorageImpl *This, - StgProperty propertyToDelete, - StgProperty parentProperty, - ULONG parentPropertyId, - INT typeOfRelation) + ULONG parentStorageIndex, + ULONG deletedIndex) { HRESULT hr = S_OK; BOOL res = TRUE; + StgProperty propertyToDelete; + StgProperty parentProperty; + ULONG parentPropertyId; + ULONG typeOfRelation; + + res = StorageImpl_ReadProperty(This, deletedIndex, &propertyToDelete); + + /* + * Find the property that links to the one we want to delete. + */ + hr = findTreeParent(This, parentStorageIndex, propertyToDelete.name, + &parentProperty, &parentPropertyId, &typeOfRelation); + + if (hr != S_OK) + return hr;
if (propertyToDelete.leftChild != PROPERTY_NULL) {