Commit 88e3c732 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

oleaut32: Use standard C functions for memory allocation in olefont.c.

parent 9ff42627
......@@ -117,7 +117,7 @@ static void HFONTItem_Delete(PHFONTItem item)
{
DeleteObject(item->gdiFont);
list_remove(&item->entry);
HeapFree(GetProcessHeap(), 0, item);
free(item);
}
/* Find hfont item entry in the list. Should be called while holding the crit sect */
......@@ -136,7 +136,7 @@ static HFONTItem *find_hfontitem(HFONT hfont)
/* Add an item to the list with one internal reference */
static HRESULT add_hfontitem(HFONT hfont)
{
HFONTItem *new_item = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_item));
HFONTItem *new_item = malloc(sizeof(*new_item));
if(!new_item) return E_OUTOFMEMORY;
......@@ -226,17 +226,6 @@ static HRESULT dec_ext_ref(HFONT hfont)
return hr;
}
static WCHAR *strdupW(const WCHAR* str)
{
WCHAR *ret;
DWORD size = (lstrlenW(str) + 1) * sizeof(WCHAR);
ret = HeapAlloc(GetProcessHeap(), 0, size);
if(ret)
memcpy(ret, str, size);
return ret;
}
/***********************************************************************
* Declaration of the implementation class for the IFont interface
*/
......@@ -621,8 +610,8 @@ static void realize_font(OLEFontImpl *This)
GetTextFaceW(hdc, ARRAY_SIZE(text_face), text_face);
if(lstrcmpiW(text_face, This->description.lpstrName))
{
HeapFree(GetProcessHeap(), 0, This->description.lpstrName);
This->description.lpstrName = strdupW(text_face);
free(This->description.lpstrName);
This->description.lpstrName = wcsdup(text_face);
}
GetTextMetricsW(hdc, &tm);
This->description.sCharset = tm.tmCharSet;
......@@ -669,8 +658,8 @@ static HRESULT WINAPI OLEFontImpl_put_Name(
if (!name)
return CTL_E_INVALIDPROPERTYVALUE;
HeapFree(GetProcessHeap(), 0, This->description.lpstrName);
This->description.lpstrName = strdupW(name);
free(This->description.lpstrName);
This->description.lpstrName = wcsdup(name);
if (!This->description.lpstrName) return E_OUTOFMEMORY;
TRACE("new name %s\n", debugstr_w(This->description.lpstrName));
......@@ -960,13 +949,13 @@ static HRESULT WINAPI OLEFontImpl_Clone(
*ppfont = NULL;
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
newObject = malloc(sizeof(OLEFontImpl));
if (newObject==NULL)
return E_OUTOFMEMORY;
*newObject = *this;
/* allocate separate buffer */
newObject->description.lpstrName = strdupW(this->description.lpstrName);
newObject->description.lpstrName = wcsdup(this->description.lpstrName);
/* Increment internal ref in hfont item list */
if(newObject->gdiFont) inc_int_ref(newObject->gdiFont);
......@@ -1623,10 +1612,10 @@ static HRESULT WINAPI OLEFontImpl_Load(
IStream_Read(pLoadStream, readBuffer, string_size, &cbRead);
if (cbRead != string_size) return E_FAIL;
HeapFree(GetProcessHeap(), 0, this->description.lpstrName);
free(this->description.lpstrName);
len = MultiByteToWideChar( CP_ACP, 0, readBuffer, string_size, NULL, 0 );
this->description.lpstrName = HeapAlloc( GetProcessHeap(), 0, (len+1) * sizeof(WCHAR) );
this->description.lpstrName = malloc((len + 1) * sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, readBuffer, string_size, this->description.lpstrName, len );
this->description.lpstrName[len] = 0;
......@@ -1697,13 +1686,13 @@ static HRESULT WINAPI OLEFontImpl_Save(
if (string_size)
{
if (!(writeBuffer = HeapAlloc( GetProcessHeap(), 0, string_size ))) return E_OUTOFMEMORY;
if (!(writeBuffer = malloc(string_size))) return E_OUTOFMEMORY;
WideCharToMultiByte( CP_ACP, 0, this->description.lpstrName,
lstrlenW(this->description.lpstrName),
writeBuffer, string_size, NULL, NULL );
IStream_Write(pOutStream, writeBuffer, string_size, &written);
HeapFree(GetProcessHeap(), 0, writeBuffer);
free(writeBuffer);
if (written != string_size) return E_FAIL;
}
......@@ -2024,7 +2013,7 @@ static OLEFontImpl* OLEFontImpl_Construct(const FONTDESC *fontDesc)
{
OLEFontImpl* newObject;
newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEFontImpl));
newObject = malloc(sizeof(OLEFontImpl));
if (newObject==0)
return newObject;
......@@ -2038,7 +2027,7 @@ static OLEFontImpl* OLEFontImpl_Construct(const FONTDESC *fontDesc)
newObject->ref = 1;
newObject->description.cbSizeofstruct = sizeof(FONTDESC);
newObject->description.lpstrName = strdupW(fontDesc->lpstrName);
newObject->description.lpstrName = wcsdup(fontDesc->lpstrName);
newObject->description.cySize = fontDesc->cySize;
newObject->description.sWeight = fontDesc->sWeight;
newObject->description.sCharset = fontDesc->sCharset;
......@@ -2079,14 +2068,14 @@ static void OLEFontImpl_Destroy(OLEFontImpl* fontDesc)
{
TRACE("(%p)\n", fontDesc);
HeapFree(GetProcessHeap(), 0, fontDesc->description.lpstrName);
free(fontDesc->description.lpstrName);
if (fontDesc->pPropertyNotifyCP)
IConnectionPoint_Release(fontDesc->pPropertyNotifyCP);
if (fontDesc->pFontEventsCP)
IConnectionPoint_Release(fontDesc->pFontEventsCP);
HeapFree(GetProcessHeap(), 0, fontDesc);
free(fontDesc);
}
/*******************************************************************************
......
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