From 1f5fb2982b95d98f3fc9a300d3519d8642400cce Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 2 Nov 2009 12:25:46 -0600 Subject: [PATCH 7/9] ole32: Add and use a destroyDirEntry function for deleting directory entries. We need this so we can free any related resources in memory. --- dlls/ole32/storage32.c | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 3af5157..e4b933e 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -183,6 +183,10 @@ static HRESULT createDirEntry( const StgProperty *newData, ULONG *index); +static HRESULT destroyDirEntry( + StorageImpl *storage, + ULONG index); + static void updatePropertyChain( StorageBaseImpl *storage, ULONG newPropertyIndex, @@ -1257,6 +1261,27 @@ static HRESULT createDirEntry( return hr; } +/*************************************************************************** + * + * Internal Method + * + * Mark a directory entry in the file as free. + */ +static HRESULT destroyDirEntry( + StorageImpl *storage, + ULONG index) +{ + HRESULT hr; + BYTE emptyData[PROPSET_BLOCK_SIZE]; + + memset(&emptyData, 0, PROPSET_BLOCK_SIZE); + + hr = StorageImpl_WriteRawDirEntry(storage, index, emptyData); + + return hr; +} + + /**************************************************************************** * * Internal Method @@ -1802,13 +1827,11 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement( foundPropertyIndexToDelete); /* - * Invalidate the property by zeroing its name member. + * Invalidate the property */ - propertyToDelete.sizeOfNameString = 0; - - StorageImpl_WriteProperty(This->ancestorStorage, - foundPropertyIndexToDelete, - &propertyToDelete); + if (SUCCEEDED(hr)) + destroyDirEntry(This->ancestorStorage, + foundPropertyIndexToDelete); return hr; } -- 1.6.3.3