Commit 0f72487b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32/filemoniker: Use CRT allocation functions.

parent b3c773af
......@@ -134,8 +134,8 @@ static ULONG WINAPI FileMonikerImpl_Release(IMoniker* iface)
if (!ref)
{
if (moniker->pMarshal) IUnknown_Release(moniker->pMarshal);
HeapFree(GetProcessHeap(), 0, moniker->filePathName);
HeapFree(GetProcessHeap(), 0, moniker);
free(moniker->filePathName);
free(moniker);
}
return ref;
......@@ -211,7 +211,7 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
}
/* read filePath string */
filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
filePathA = malloc(bytesA);
if (!filePathA)
{
res = E_OUTOFMEMORY;
......@@ -262,7 +262,7 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
if (!len)
goto fail;
filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
filePathW = malloc((len + 1) * sizeof(WCHAR));
if (!filePathW)
{
res = E_OUTOFMEMORY;
......@@ -286,7 +286,7 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
goto fail;
len=bytesW/sizeof(WCHAR);
filePathW=HeapAlloc(GetProcessHeap(),0,(len+1)*sizeof(WCHAR));
filePathW = malloc((len + 1) * sizeof(WCHAR));
if(!filePathW)
{
res = E_OUTOFMEMORY;
......@@ -299,15 +299,15 @@ FileMonikerImpl_Load(IMoniker* iface, IStream* pStm)
filePathW[len]=0;
succeed:
HeapFree(GetProcessHeap(),0,filePathA);
HeapFree(GetProcessHeap(),0,This->filePathName);
free(filePathA);
free(This->filePathName);
This->filePathName=filePathW;
return S_OK;
fail:
HeapFree(GetProcessHeap(), 0, filePathA);
HeapFree(GetProcessHeap(), 0, filePathW);
free(filePathA);
free(filePathW);
if (SUCCEEDED(res))
res = E_FAIL;
......@@ -372,12 +372,12 @@ FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
if (FAILED(res)) return res;
/* write A string (with '\0') */
filePathA=HeapAlloc(GetProcessHeap(),0,bytesA);
filePathA = malloc(bytesA);
if (!filePathA)
return E_OUTOFMEMORY;
WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
res=IStream_Write(pStm,filePathA,bytesA,NULL);
HeapFree(GetProcessHeap(),0,filePathA);
free(filePathA);
if (FAILED(res)) return res;
/* write a WORD 0xFFFF */
......@@ -758,7 +758,7 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
lastIdx1-=2;
/* the length of the composed path string is increased by the sum of the two paths' lengths */
newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
newStr = malloc(sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
if (newStr){
/* new path is the concatenation of the rest of str1 and str2 */
......@@ -774,8 +774,7 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
/* create a new moniker with the new string */
res=CreateFileMoniker(newStr,ppmkComposite);
/* free string memory used by this function */
HeapFree(GetProcessHeap(),0,newStr);
free(newStr);
}
else res = E_OUTOFMEMORY;
}
......@@ -1098,7 +1097,7 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
/* begin the construction of relativePath */
/* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */
/* by "..\\" in the begin */
relPath=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
relPath = malloc(sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
*relPath=0;
......@@ -1117,7 +1116,7 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
free_stringtable(tabStr2);
CoTaskMemFree(str1);
CoTaskMemFree(str2);
HeapFree(GetProcessHeap(),0,relPath);
free(relPath);
if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0))
return MK_S_HIM;
......@@ -1305,7 +1304,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
This->ref = 0;
This->pMarshal = NULL;
This->filePathName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr+1));
This->filePathName = malloc(sizeof(WCHAR)*(sizeStr+1));
if (This->filePathName==NULL)
return E_OUTOFMEMORY;
......@@ -1341,7 +1340,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
if (!wcscmp(tabStr[nb-1], L"\\"))
addBkSlash = FALSE;
This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
This->filePathName = realloc(This->filePathName, (sizeStr+1)*sizeof(WCHAR));
*This->filePathName=0;
......@@ -1362,10 +1361,10 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
******************************************************************************/
HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
{
FileMonikerImpl* newFileMoniker;
FileMonikerImpl *moniker;
HRESULT hr;
TRACE("(%s,%p)\n",debugstr_w(lpszPathName),ppmk);
TRACE("%s, %p.\n", debugstr_w(lpszPathName), ppmk);
if (!ppmk)
return E_POINTER;
......@@ -1375,17 +1374,15 @@ HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
*ppmk=NULL;
newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
if (!newFileMoniker)
if (!(moniker = calloc(1, sizeof(*moniker))))
return E_OUTOFMEMORY;
hr = FileMonikerImpl_Construct(newFileMoniker,lpszPathName);
hr = FileMonikerImpl_Construct(moniker, lpszPathName);
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface,&IID_IMoniker,(void**)ppmk);
hr = IMoniker_QueryInterface(&moniker->IMoniker_iface, &IID_IMoniker, (void **)ppmk);
else
HeapFree(GetProcessHeap(),0,newFileMoniker);
free(moniker);
return hr;
}
......@@ -1415,7 +1412,7 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
DWORD full_path_name_len;
int len = end - szDisplayName;
file_display_name = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
file_display_name = malloc((len + 1) * sizeof(WCHAR));
if (!file_display_name) return E_OUTOFMEMORY;
memcpy(file_display_name, szDisplayName, len * sizeof(WCHAR));
file_display_name[len] = '\0';
......@@ -1423,14 +1420,14 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
hr = CreateFileMoniker(file_display_name, &file_moniker);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
return hr;
}
hr = IBindCtx_GetRunningObjectTable(pbc, &rot);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
IMoniker_Release(file_moniker);
return hr;
}
......@@ -1439,7 +1436,7 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
IRunningObjectTable_Release(rot);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
IMoniker_Release(file_moniker);
return hr;
}
......@@ -1448,21 +1445,21 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
TRACE("found running file moniker for %s\n", debugstr_w(file_display_name));
*pchEaten = len;
*ppmk = file_moniker;
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
return S_OK;
}
full_path_name_len = GetFullPathNameW(file_display_name, 0, NULL, NULL);
if (!full_path_name_len)
{
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
IMoniker_Release(file_moniker);
return MK_E_SYNTAX;
}
full_path_name = HeapAlloc(GetProcessHeap(), 0, full_path_name_len * sizeof(WCHAR));
full_path_name = malloc(full_path_name_len * sizeof(WCHAR));
if (!full_path_name)
{
HeapFree(GetProcessHeap(), 0, file_display_name);
free(file_display_name);
IMoniker_Release(file_moniker);
return E_OUTOFMEMORY;
}
......@@ -1475,12 +1472,12 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
TRACE("got file moniker for %s\n", debugstr_w(szDisplayName));
*pchEaten = len;
*ppmk = file_moniker;
HeapFree(GetProcessHeap(), 0, file_display_name);
HeapFree(GetProcessHeap(), 0, full_path_name);
free(file_display_name);
free(full_path_name);
return S_OK;
}
HeapFree(GetProcessHeap(), 0, file_display_name);
HeapFree(GetProcessHeap(), 0, full_path_name);
free(file_display_name);
free(full_path_name);
IMoniker_Release(file_moniker);
}
......@@ -1500,7 +1497,7 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
if (pUnk)
return CLASS_E_NOAGGREGATION;
newFileMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(FileMonikerImpl));
newFileMoniker = calloc(1, sizeof(*newFileMoniker));
if (!newFileMoniker)
return E_OUTOFMEMORY;
......@@ -1509,7 +1506,7 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
if (FAILED(hr))
HeapFree(GetProcessHeap(),0,newFileMoniker);
free(newFileMoniker);
return hr;
}
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