Commit 13b96664 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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.
parent fd993b7d
...@@ -169,12 +169,10 @@ static HRESULT deleteStreamProperty( ...@@ -169,12 +169,10 @@ static HRESULT deleteStreamProperty(
ULONG foundPropertyIndexToDelete, ULONG foundPropertyIndexToDelete,
StgProperty propertyToDelete); StgProperty propertyToDelete);
static HRESULT adjustPropertyChain( static HRESULT removeFromTree(
StorageImpl *This, StorageImpl *This,
StgProperty propertyToDelete, ULONG parentStorageIndex,
StgProperty parentProperty, ULONG deletedIndex);
ULONG parentPropertyId,
INT typeOfRelation);
/*********************************************************************** /***********************************************************************
* Declaration of the functions used to manipulate StgProperty * Declaration of the functions used to manipulate StgProperty
...@@ -1755,10 +1753,7 @@ static HRESULT WINAPI StorageImpl_DestroyElement( ...@@ -1755,10 +1753,7 @@ static HRESULT WINAPI StorageImpl_DestroyElement(
HRESULT hr = S_OK; HRESULT hr = S_OK;
StgProperty propertyToDelete; StgProperty propertyToDelete;
StgProperty parentProperty;
ULONG foundPropertyIndexToDelete; ULONG foundPropertyIndexToDelete;
ULONG typeOfRelation;
ULONG parentPropertyId = 0;
TRACE("(%p, %s)\n", TRACE("(%p, %s)\n",
iface, debugstr_w(pwcsName)); iface, debugstr_w(pwcsName));
...@@ -1780,15 +1775,6 @@ static HRESULT WINAPI StorageImpl_DestroyElement( ...@@ -1780,15 +1775,6 @@ static HRESULT WINAPI StorageImpl_DestroyElement(
return STG_E_FILENOTFOUND; 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 ) if ( propertyToDelete.propertyType == PROPTYPE_STORAGE )
{ {
hr = deleteStorageProperty( hr = deleteStorageProperty(
...@@ -1810,12 +1796,10 @@ static HRESULT WINAPI StorageImpl_DestroyElement( ...@@ -1810,12 +1796,10 @@ static HRESULT WINAPI StorageImpl_DestroyElement(
/* /*
* Adjust the property chain * Adjust the property chain
*/ */
hr = adjustPropertyChain( hr = removeFromTree(
This, This->base.ancestorStorage,
propertyToDelete, This->base.rootPropertySetIndex,
parentProperty, foundPropertyIndexToDelete);
parentPropertyId,
typeOfRelation);
/* /*
* Invalidate the property by zeroing its name member. * Invalidate the property by zeroing its name member.
...@@ -2018,18 +2002,31 @@ static void setPropertyLink(StgProperty *property, ULONG relation, ULONG new_tar ...@@ -2018,18 +2002,31 @@ static void setPropertyLink(StgProperty *property, ULONG relation, ULONG new_tar
* *
* Internal Method * Internal Method
* *
* This method takes the previous and the next property link of a property * This method removes a directory entry from its parent storage tree without
* to be deleted and find them a place in the Storage. * freeing any resources attached to it.
*/ */
static HRESULT adjustPropertyChain( static HRESULT removeFromTree(
StorageImpl *This, StorageImpl *This,
StgProperty propertyToDelete, ULONG parentStorageIndex,
StgProperty parentProperty, ULONG deletedIndex)
ULONG parentPropertyId,
INT typeOfRelation)
{ {
HRESULT hr = S_OK; HRESULT hr = S_OK;
BOOL res = TRUE; 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) if (propertyToDelete.leftChild != PROPERTY_NULL)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment