ole32: Add helper for string table memory freeing.

This commit is contained in:
Frédéric Delanoy 2012-11-26 12:41:41 +01:00 committed by Alexandre Julliard
parent 380d0cd023
commit 02da0411e1
1 changed files with 17 additions and 26 deletions

View File

@ -657,6 +657,15 @@ FileMonikerImpl_Reduce(IMoniker* iface, IBindCtx* pbc, DWORD dwReduceHowFar,
return MK_S_REDUCED_TO_SELF;
}
static void free_stringtable(LPOLESTR *stringTable)
{
int i;
for (i=0; stringTable[i]!=NULL; i++)
CoTaskMemFree(stringTable[i]);
CoTaskMemFree(stringTable);
}
/******************************************************************************
* FileMoniker_ComposeWith
*/
@ -731,12 +740,8 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
}
else res = E_OUTOFMEMORY;
for(i=0; strDec1[i]!=NULL;i++)
CoTaskMemFree(strDec1[i]);
for(i=0; strDec2[i]!=NULL;i++)
CoTaskMemFree(strDec2[i]);
CoTaskMemFree(strDec1);
CoTaskMemFree(strDec2);
free_stringtable(strDec1);
free_stringtable(strDec2);
CoTaskMemFree(str1);
CoTaskMemFree(str2);
@ -1004,17 +1009,9 @@ FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** p
{
for(i=0;i<sameIdx;i++)
strcatW(commonPath,stringTable1[i]);
for(i=0;i<nb1;i++)
CoTaskMemFree(stringTable1[i]);
CoTaskMemFree(stringTable1);
for(i=0;i<nb2;i++)
CoTaskMemFree(stringTable2[i]);
CoTaskMemFree(stringTable2);
free_stringtable(stringTable1);
free_stringtable(stringTable2);
ret = CreateFileMoniker(commonPath,ppmkPrefix);
}
HeapFree(GetProcessHeap(),0,commonPath);
@ -1167,12 +1164,8 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
res=CreateFileMoniker(relPath,ppmkRelPath);
for(j=0; tabStr1[j]!=NULL;j++)
CoTaskMemFree(tabStr1[j]);
for(j=0; tabStr2[j]!=NULL;j++)
CoTaskMemFree(tabStr2[j]);
CoTaskMemFree(tabStr1);
CoTaskMemFree(tabStr2);
free_stringtable(tabStr1);
free_stringtable(tabStr2);
CoTaskMemFree(str1);
CoTaskMemFree(str2);
HeapFree(GetProcessHeap(),0,relPath);
@ -1410,9 +1403,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
strcatW(This->filePathName,bkSlash);
}
for(i=0; tabStr[i]!=NULL;i++)
CoTaskMemFree(tabStr[i]);
CoTaskMemFree(tabStr);
free_stringtable(tabStr);
return S_OK;
}