Commit 69d81540 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

gdiplus: Use CRT allocation functions.

parent a3f4878f
......@@ -40,9 +40,9 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
return InvalidParameter;
if (from->type == CustomLineCapTypeDefault)
*to = heap_alloc_zero(sizeof(GpCustomLineCap));
*to = malloc(sizeof(GpCustomLineCap));
else
*to = heap_alloc_zero(sizeof(GpAdjustableArrowCap));
*to = malloc(sizeof(GpAdjustableArrowCap));
if (!*to)
return OutOfMemory;
......@@ -53,13 +53,13 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
*(GpAdjustableArrowCap *)*to = *(GpAdjustableArrowCap *)from;
/* Duplicate path data */
(*to)->pathdata.Points = heap_alloc_zero(from->pathdata.Count * sizeof(PointF));
(*to)->pathdata.Types = heap_alloc_zero(from->pathdata.Count);
(*to)->pathdata.Points = malloc(from->pathdata.Count * sizeof(PointF));
(*to)->pathdata.Types = malloc(from->pathdata.Count);
if((!(*to)->pathdata.Types || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
heap_free((*to)->pathdata.Points);
heap_free((*to)->pathdata.Types);
heap_free(*to);
free((*to)->pathdata.Points);
free((*to)->pathdata.Types);
free(*to);
return OutOfMemory;
}
......@@ -77,13 +77,13 @@ static GpStatus init_custom_linecap(GpCustomLineCap *cap, GpPathData *pathdata,
{
cap->fill = fill;
cap->pathdata.Points = heap_alloc_zero(pathdata->Count * sizeof(PointF));
cap->pathdata.Types = heap_alloc_zero(pathdata->Count);
cap->pathdata.Points = malloc(pathdata->Count * sizeof(PointF));
cap->pathdata.Types = malloc(pathdata->Count);
if ((!cap->pathdata.Types || !cap->pathdata.Points) && pathdata->Count)
{
heap_free(cap->pathdata.Points);
heap_free(cap->pathdata.Types);
free(cap->pathdata.Points);
free(cap->pathdata.Types);
cap->pathdata.Points = NULL;
cap->pathdata.Types = NULL;
return OutOfMemory;
......@@ -119,8 +119,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
if(!customCap || !(fillPath || strokePath))
return InvalidParameter;
*customCap = heap_alloc_zero(sizeof(GpCustomLineCap));
if(!*customCap) return OutOfMemory;
*customCap = calloc(1, sizeof(GpCustomLineCap));
if(!*customCap) return OutOfMemory;
if (strokePath)
pathdata = &strokePath->pathdata;
......@@ -130,7 +130,7 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
stat = init_custom_linecap(*customCap, pathdata, fillPath != NULL, baseCap, baseInset);
if (stat != Ok)
{
heap_free(*customCap);
free(*customCap);
return stat;
}
......@@ -146,9 +146,9 @@ GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
if(!customCap)
return InvalidParameter;
heap_free(customCap->pathdata.Points);
heap_free(customCap->pathdata.Types);
heap_free(customCap);
free(customCap->pathdata.Points);
free(customCap->pathdata.Types);
free(customCap);
return Ok;
}
......@@ -337,7 +337,7 @@ GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL f
if (!cap)
return InvalidParameter;
*cap = heap_alloc_zero(sizeof(**cap));
*cap = calloc(1, sizeof(**cap));
if (!*cap)
return OutOfMemory;
......@@ -348,7 +348,7 @@ GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL f
stat = init_custom_linecap(&(*cap)->cap, &pathdata, fill, LineCapTriangle, width != 0.0 ? height / width : 0.0);
if (stat != Ok)
{
heap_free(*cap);
free(*cap);
return stat;
}
......
......@@ -185,7 +185,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
if (!ret) return NotTrueTypeFont;
*font = heap_alloc_zero(sizeof(GpFont));
*font = calloc(1, sizeof(GpFont));
if (!*font) return OutOfMemory;
(*font)->unit = unit;
......@@ -225,7 +225,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
if (!ret) return NotTrueTypeFont;
*font = heap_alloc_zero(sizeof(GpFont));
*font = calloc(1, sizeof(GpFont));
if (!*font) return OutOfMemory;
(*font)->unit = UnitWorld;
......@@ -235,7 +235,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family);
if (stat != Ok)
{
heap_free(*font);
free(*font);
return NotTrueTypeFont;
}
......@@ -276,7 +276,7 @@ GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
return InvalidParameter;
GdipDeleteFontFamily(font->family);
heap_free(font);
free(font);
return Ok;
}
......@@ -506,8 +506,8 @@ GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
if(!font || !cloneFont)
return InvalidParameter;
*cloneFont = heap_alloc_zero(sizeof(GpFont));
if(!*cloneFont) return OutOfMemory;
*cloneFont = calloc(1, sizeof(GpFont));
if(!*cloneFont) return OutOfMemory;
**cloneFont = *font;
return Ok;
......@@ -824,7 +824,7 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
if (!FontFamily->installed && !InterlockedDecrement(&FontFamily->ref))
{
heap_free(FontFamily);
free(FontFamily);
}
return Ok;
......@@ -1057,7 +1057,7 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti
if (!fontCollection)
return InvalidParameter;
*fontCollection = heap_alloc_zero(sizeof(GpFontCollection));
*fontCollection = calloc(1, sizeof(GpFontCollection));
if (!*fontCollection) return OutOfMemory;
(*fontCollection)->FontFamilies = NULL;
......@@ -1082,8 +1082,8 @@ GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontColle
return InvalidParameter;
for (i = 0; i < (*fontCollection)->count; i++) GdipDeleteFontFamily((*fontCollection)->FontFamilies[i]);
heap_free((*fontCollection)->FontFamilies);
heap_free(*fontCollection);
free((*fontCollection)->FontFamilies);
free(*fontCollection);
return Ok;
}
......@@ -1364,7 +1364,7 @@ static WCHAR *copy_name_table_string( const tt_name_record *name, const BYTE *da
{
case TT_PLATFORM_APPLE_UNICODE:
case TT_PLATFORM_MICROSOFT:
ret = heap_alloc((name_len / 2 + 1) * sizeof(WCHAR));
ret = malloc((name_len / 2 + 1) * sizeof(WCHAR));
for (len = 0; len < name_len / 2; len++)
ret[len] = (data[len * 2] << 8) | data[len * 2 + 1];
ret[len] = 0;
......@@ -1374,7 +1374,7 @@ static WCHAR *copy_name_table_string( const tt_name_record *name, const BYTE *da
len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, NULL, 0 ) + 1;
if (!len)
return NULL;
ret = heap_alloc(len * sizeof(WCHAR));
ret = malloc(len * sizeof(WCHAR));
len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, ret, len - 1 );
ret[len] = 0;
return ret;
......@@ -1509,7 +1509,7 @@ GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
DeleteDC(param.hdc);
}
heap_free(name);
free(name);
return ret;
}
......@@ -1560,8 +1560,8 @@ void free_installed_fonts(void)
INT i;
for (i = 0; i < installedFontCollection.count; i++)
heap_free(installedFontCollection.FontFamilies[i]);
heap_free(installedFontCollection.FontFamilies);
free(installedFontCollection.FontFamilies[i]);
free(installedFontCollection.FontFamilies);
installedFontCollection.FontFamilies = NULL;
installedFontCollection.allocated = 0;
......@@ -1592,7 +1592,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
if (fonts->allocated == fonts->count)
{
INT new_alloc_count = fonts->allocated+50;
GpFontFamily** new_family_list = heap_alloc(new_alloc_count*sizeof(void*));
GpFontFamily** new_family_list = malloc(new_alloc_count * sizeof(void*));
if (!new_family_list)
{
......@@ -1601,12 +1601,12 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
}
memcpy(new_family_list, fonts->FontFamilies, fonts->count*sizeof(void*));
heap_free(fonts->FontFamilies);
free(fonts->FontFamilies);
fonts->FontFamilies = new_family_list;
fonts->allocated = new_alloc_count;
}
family = heap_alloc(sizeof(*family));
family = malloc(sizeof(*family));
if (!family)
{
if (param->is_system)
......@@ -1621,7 +1621,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
{
if (wcsicmp(lfw->lfFaceName, fonts->FontFamilies[i]->FamilyName) == 0)
{
heap_free(family);
free(family);
return 1;
}
}
......@@ -1634,7 +1634,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
SelectObject(param->hdc, old_hfont);
DeleteObject(hfont);
heap_free(family);
free(family);
param->stat = OutOfMemory;
return 0;
}
......
......@@ -143,7 +143,7 @@ ULONG WINAPI GdiplusShutdown_wrapper(ULONG_PTR token)
*/
void* WINGDIPAPI GdipAlloc(SIZE_T size)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
return calloc(1, size);
}
/*****************************************************
......@@ -151,7 +151,7 @@ void* WINGDIPAPI GdipAlloc(SIZE_T size)
*/
void WINGDIPAPI GdipFree(void* ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
free(ptr);
}
/* Calculates the bezier points needed to fill in the arc portion starting at
......@@ -418,12 +418,12 @@ BOOL lengthen_path(GpPath *path, INT len)
if(path->datalen == 0){
path->datalen = len * 2;
path->pathdata.Points = heap_alloc_zero(path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Points = calloc(path->datalen, sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = heap_alloc_zero(path->datalen);
path->pathdata.Types = calloc(1, path->datalen);
if(!path->pathdata.Types){
heap_free(path->pathdata.Points);
free(path->pathdata.Points);
return FALSE;
}
}
......@@ -432,11 +432,11 @@ BOOL lengthen_path(GpPath *path, INT len)
while(path->datalen - path->pathdata.Count < len)
path->datalen *= 2;
path->pathdata.Points = heap_realloc(path->pathdata.Points, path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Points = realloc(path->pathdata.Points, path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = heap_realloc(path->pathdata.Types, path->datalen);
if(!path->pathdata.Types) return FALSE;
path->pathdata.Types = realloc(path->pathdata.Types, path->datalen);
if(!path->pathdata.Types) return FALSE;
}
return TRUE;
......@@ -477,8 +477,8 @@ void delete_element(region_element* element)
default:
delete_element(element->elementdata.combine.left);
delete_element(element->elementdata.combine.right);
heap_free(element->elementdata.combine.left);
heap_free(element->elementdata.combine.right);
free(element->elementdata.combine.left);
free(element->elementdata.combine.right);
break;
}
}
......
......@@ -30,7 +30,6 @@
#include "objbase.h"
#include "ocidl.h"
#include "wincodecsdk.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "gdiplus.h"
......
......@@ -45,7 +45,7 @@ GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imagea
{
remap_tables[i].enabled = TRUE;
remap_tables[i].mapsize = imageattr->colorremaptables[i].mapsize;
remap_tables[i].colormap = heap_alloc(sizeof(ColorMap) * remap_tables[i].mapsize);
remap_tables[i].colormap = malloc(sizeof(ColorMap) * remap_tables[i].mapsize);
if (remap_tables[i].colormap)
{
......@@ -73,7 +73,7 @@ GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imagea
if (stat != Ok)
{
for (i=0; i<ColorAdjustTypeCount; i++)
heap_free(remap_tables[i].colormap);
free(remap_tables[i].colormap);
}
return stat;
......@@ -84,8 +84,8 @@ GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
if(!imageattr)
return InvalidParameter;
*imageattr = heap_alloc_zero(sizeof(GpImageAttributes));
if(!*imageattr) return OutOfMemory;
*imageattr = calloc(1, sizeof(GpImageAttributes));
if(!*imageattr) return OutOfMemory;
(*imageattr)->wrap = WrapModeClamp;
......@@ -104,9 +104,9 @@ GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
return InvalidParameter;
for (i=0; i<ColorAdjustTypeCount; i++)
heap_free(imageattr->colorremaptables[i].colormap);
free(imageattr->colorremaptables[i].colormap);
heap_free(imageattr);
free(imageattr);
return Ok;
}
......@@ -271,21 +271,21 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
if(!map || !mapSize)
return InvalidParameter;
new_map = heap_alloc_zero(sizeof(*map) * mapSize);
new_map = malloc(sizeof(*map) * mapSize);
if (!new_map)
return OutOfMemory;
memcpy(new_map, map, sizeof(*map) * mapSize);
heap_free(imageAttr->colorremaptables[type].colormap);
free(imageAttr->colorremaptables[type].colormap);
imageAttr->colorremaptables[type].mapsize = mapSize;
imageAttr->colorremaptables[type].colormap = new_map;
}
else
{
heap_free(imageAttr->colorremaptables[type].colormap);
free(imageAttr->colorremaptables[type].colormap);
imageAttr->colorremaptables[type].colormap = NULL;
}
......
......@@ -64,8 +64,8 @@ GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22,
if(!matrix)
return InvalidParameter;
*matrix = heap_alloc_zero(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
*matrix = malloc(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
/* first row */
(*matrix)->matrix[0] = m11;
......@@ -125,8 +125,8 @@ GpStatus WINGDIPAPI GdipCloneMatrix(GpMatrix *matrix, GpMatrix **clone)
if(!matrix || !clone)
return InvalidParameter;
*clone = heap_alloc_zero(sizeof(GpMatrix));
if(!*clone) return OutOfMemory;
*clone = malloc(sizeof(GpMatrix));
if(!*clone) return OutOfMemory;
**clone = *matrix;
......@@ -140,8 +140,8 @@ GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
if(!matrix)
return InvalidParameter;
*matrix = heap_alloc_zero(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
*matrix = malloc(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
(*matrix)->matrix[0] = 1.0;
(*matrix)->matrix[1] = 0.0;
......@@ -160,7 +160,7 @@ GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
if(!matrix)
return InvalidParameter;
heap_free(matrix);
free(matrix);
return Ok;
}
......@@ -396,7 +396,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
if(count <= 0)
return InvalidParameter;
ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
ptsF = malloc(sizeof(GpPointF) * count);
if(!ptsF)
return OutOfMemory;
......@@ -412,7 +412,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
pts[i].X = gdip_round(ptsF[i].X);
pts[i].Y = gdip_round(ptsF[i].Y);
}
heap_free(ptsF);
free(ptsF);
return ret;
}
......@@ -476,7 +476,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
if(count <= 0)
return InvalidParameter;
ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
ptsF = malloc(sizeof(GpPointF) * count);
if(!ptsF)
return OutOfMemory;
......@@ -492,7 +492,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
pts[i].X = gdip_round(ptsF[i].X);
pts[i].Y = gdip_round(ptsF[i].Y);
}
heap_free(ptsF);
free(ptsF);
return ret;
}
......
......@@ -40,14 +40,14 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
if(!iterator)
return InvalidParameter;
*iterator = heap_alloc_zero(sizeof(GpPathIterator));
if(!*iterator) return OutOfMemory;
*iterator = calloc(1, sizeof(GpPathIterator));
if(!*iterator) return OutOfMemory;
if(path){
size = path->pathdata.Count;
(*iterator)->pathdata.Types = heap_alloc_zero(size);
(*iterator)->pathdata.Points = heap_alloc_zero(size * sizeof(PointF));
(*iterator)->pathdata.Types = malloc(size);
(*iterator)->pathdata.Points = malloc(size * sizeof(PointF));
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
......@@ -73,9 +73,9 @@ GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
if(!iter)
return InvalidParameter;
heap_free(iter->pathdata.Types);
heap_free(iter->pathdata.Points);
heap_free(iter);
free(iter->pathdata.Types);
free(iter->pathdata.Points);
free(iter);
return Ok;
}
......
......@@ -94,8 +94,8 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if(!pen || !clonepen)
return InvalidParameter;
*clonepen = heap_alloc_zero(sizeof(GpPen));
if(!*clonepen) return OutOfMemory;
*clonepen = malloc(sizeof(GpPen));
if(!*clonepen) return OutOfMemory;
**clonepen = *pen;
......@@ -115,7 +115,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if (stat == Ok && pen->dashes)
{
(*clonepen)->dashes = heap_alloc_zero(pen->numdashes * sizeof(REAL));
(*clonepen)->dashes = malloc(pen->numdashes * sizeof(REAL));
if ((*clonepen)->dashes)
memcpy((*clonepen)->dashes, pen->dashes, pen->numdashes * sizeof(REAL));
else
......@@ -124,7 +124,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if (stat == Ok && pen->compound_array)
{
(*clonepen)->compound_array = heap_alloc_zero(pen->compound_array_size * sizeof(REAL));
(*clonepen)->compound_array = malloc(pen->compound_array_size * sizeof(REAL));
if ((*clonepen)->compound_array)
memcpy((*clonepen)->compound_array, pen->compound_array, pen->compound_array_size * sizeof(REAL));
else
......@@ -168,8 +168,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
if(!pen || !brush)
return InvalidParameter;
gp_pen = heap_alloc_zero(sizeof(GpPen));
if(!gp_pen) return OutOfMemory;
gp_pen = calloc(1, sizeof(GpPen));
if(!gp_pen) return OutOfMemory;
gp_pen->style = GP_DEFAULT_PENSTYLE;
gp_pen->width = width;
......@@ -187,7 +187,7 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) {
FIXME("UnitWorld, UnitPixel only supported units\n");
heap_free(gp_pen);
free(gp_pen);
return NotImplemented;
}
......@@ -210,9 +210,9 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
GdipDeleteBrush(pen->brush);
GdipDeleteCustomLineCap(pen->customstart);
GdipDeleteCustomLineCap(pen->customend);
heap_free(pen->compound_array);
heap_free(pen->dashes);
heap_free(pen);
free(pen->compound_array);
free(pen->dashes);
free(pen);
return Ok;
}
......@@ -577,10 +577,10 @@ GpStatus WINGDIPAPI GdipSetPenCompoundArray(GpPen *pen, GDIPCONST REAL *compound
return InvalidParameter;
}
tmp = heap_alloc_zero(count * sizeof(REAL));
tmp = malloc(count * sizeof(REAL));
if(!tmp)
return OutOfMemory;
heap_free(pen->compound_array);
free(pen->compound_array);
pen->compound_array = tmp;
memcpy(pen->compound_array, compoundarray, count * sizeof(REAL));
pen->compound_array_size = count;
......@@ -643,11 +643,11 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
return InvalidParameter;
}
heap_free(pen->dashes);
free(pen->dashes);
pen->dashes = NULL;
if(count > 0)
pen->dashes = heap_alloc_zero(count * sizeof(REAL));
pen->dashes = malloc(count * sizeof(REAL));
if(!pen->dashes){
pen->numdashes = 0;
return OutOfMemory;
......@@ -693,7 +693,7 @@ GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
return InvalidParameter;
if(dash != DashStyleCustom){
heap_free(pen->dashes);
free(pen->dashes);
pen->dashes = NULL;
pen->numdashes = 0;
}
......
......@@ -144,7 +144,7 @@ static inline GpStatus clone_element(const region_element* element,
/* root node is allocated with GpRegion */
if(!*element2){
*element2 = heap_alloc_zero(sizeof(region_element));
*element2 = calloc(1, sizeof(region_element));
if (!*element2)
return OutOfMemory;
}
......@@ -217,7 +217,7 @@ GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
if (!(region && clone))
return InvalidParameter;
*clone = heap_alloc_zero(sizeof(GpRegion));
*clone = calloc(1, sizeof(GpRegion));
if (!*clone)
return OutOfMemory;
element = &(*clone)->node;
......@@ -248,11 +248,11 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, path_region, sizeof(GpRegion));
heap_free(path_region);
free(path_region);
return Ok;
}
left = heap_alloc_zero(sizeof(region_element));
left = malloc(sizeof(region_element));
if (left)
{
*left = region->node;
......@@ -267,7 +267,7 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
else
stat = OutOfMemory;
heap_free(left);
free(left);
GdipDeleteRegion(path_region);
return stat;
}
......@@ -295,11 +295,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, rect_region, sizeof(GpRegion));
heap_free(rect_region);
free(rect_region);
return Ok;
}
left = heap_alloc_zero(sizeof(region_element));
left = malloc(sizeof(region_element));
if (left)
{
memcpy(left, &region->node, sizeof(region_element));
......@@ -314,7 +314,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
else
stat = OutOfMemory;
heap_free(left);
free(left);
GdipDeleteRegion(rect_region);
return stat;
}
......@@ -358,11 +358,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
delete_element(&region1->node);
memcpy(region1, reg2copy, sizeof(GpRegion));
heap_free(reg2copy);
free(reg2copy);
return Ok;
}
left = heap_alloc_zero(sizeof(region_element));
left = malloc(sizeof(region_element));
if (!left)
return OutOfMemory;
......@@ -370,7 +370,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
stat = clone_element(&region2->node, &right);
if (stat != Ok)
{
heap_free(left);
free(left);
return OutOfMemory;
}
......@@ -390,7 +390,7 @@ GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
if(!region)
return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion));
*region = calloc(1, sizeof(GpRegion));
if(!*region)
return OutOfMemory;
......@@ -428,7 +428,7 @@ GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
if (!(path && region))
return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion));
*region = calloc(1, sizeof(GpRegion));
if(!*region)
return OutOfMemory;
stat = init_region(*region, RegionDataPath);
......@@ -462,7 +462,7 @@ GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
if (!(rect && region))
return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion));
*region = calloc(1, sizeof(GpRegion));
stat = init_region(*region, RegionDataRect);
if(stat != Ok)
{
......@@ -510,32 +510,32 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
if(!region || !(size = GetRegionData(hrgn, 0, NULL)))
return InvalidParameter;
buf = heap_alloc_zero(size);
buf = malloc(size);
if(!buf)
return OutOfMemory;
if(!GetRegionData(hrgn, size, buf)){
heap_free(buf);
free(buf);
return GenericError;
}
if(buf->rdh.nCount == 0){
if((stat = GdipCreateRegion(&local)) != Ok){
heap_free(buf);
free(buf);
return stat;
}
if((stat = GdipSetEmpty(local)) != Ok){
heap_free(buf);
free(buf);
GdipDeleteRegion(local);
return stat;
}
*region = local;
heap_free(buf);
free(buf);
return Ok;
}
if((stat = GdipCreatePath(FillModeAlternate, &path)) != Ok){
heap_free(buf);
free(buf);
return stat;
}
......@@ -543,7 +543,7 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
for(i = 0; i < buf->rdh.nCount; i++){
if((stat = GdipAddPathRectangle(path, (REAL)rect->left, (REAL)rect->top,
(REAL)(rect->right - rect->left), (REAL)(rect->bottom - rect->top))) != Ok){
heap_free(buf);
free(buf);
GdipDeletePath(path);
return stat;
}
......@@ -552,7 +552,7 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
stat = GdipCreateRegionPath(path, region);
heap_free(buf);
free(buf);
GdipDeletePath(path);
return stat;
}
......@@ -568,7 +568,7 @@ GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
return InvalidParameter;
delete_element(&region->node);
heap_free(region);
free(region);
return Ok;
}
......@@ -787,12 +787,12 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
{
region_element *left, *right;
left = heap_alloc_zero(sizeof(region_element));
left = calloc(1, sizeof(region_element));
if (!left) return OutOfMemory;
right = heap_alloc_zero(sizeof(region_element));
right = calloc(1, sizeof(region_element));
if (!right)
{
heap_free(left);
free(left);
return OutOfMemory;
}
......@@ -809,8 +809,8 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
}
}
heap_free(left);
heap_free(right);
free(left);
free(right);
return status;
}
......@@ -1447,7 +1447,7 @@ static GpStatus transform_region_element(region_element* element, GpMatrix *matr
{
/* Steal the element from the created region. */
memcpy(element, &new_region->node, sizeof(region_element));
heap_free(new_region);
free(new_region);
}
else
return stat;
......@@ -1553,7 +1553,7 @@ static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGND
{
data_size = GetRegionData(hrgn, 0, NULL);
*data = heap_alloc_zero(data_size);
*data = malloc(data_size);
if (*data)
GetRegionData(hrgn, data_size, *data);
......@@ -1566,7 +1566,7 @@ static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGND
{
data_size = sizeof(RGNDATAHEADER) + sizeof(RECT);
*data = heap_alloc_zero(data_size);
*data = calloc(1, data_size);
if (*data)
{
......@@ -1605,7 +1605,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMat
if (stat == Ok)
{
*count = data->rdh.nCount;
heap_free(data);
free(data);
}
return stat;
......@@ -1639,7 +1639,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *co
}
}
heap_free(data);
free(data);
}
return Ok;
......@@ -1673,7 +1673,7 @@ GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *co
}
}
heap_free(data);
free(data);
}
return Ok;
......
......@@ -66,11 +66,11 @@ void init_generic_string_formats(void)
void free_generic_string_formats(void)
{
heap_free(generic_default_format.character_ranges);
heap_free(generic_default_format.tabs);
free(generic_default_format.character_ranges);
free(generic_default_format.tabs);
heap_free(generic_typographic_format.character_ranges);
heap_free(generic_typographic_format.tabs);
free(generic_typographic_format.character_ranges);
free(generic_typographic_format.tabs);
}
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
......@@ -81,8 +81,8 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
if(!format)
return InvalidParameter;
*format = heap_alloc_zero(sizeof(GpStringFormat));
if(!*format) return OutOfMemory;
*format = calloc(1, sizeof(GpStringFormat));
if(!*format) return OutOfMemory;
(*format)->attr = attr;
(*format)->lang = lang;
......@@ -110,9 +110,9 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
if (format == &generic_default_format || format == &generic_typographic_format)
return Ok;
heap_free(format->character_ranges);
heap_free(format->tabs);
heap_free(format);
free(format->character_ranges);
free(format->tabs);
free(format);
return Ok;
}
......@@ -297,11 +297,11 @@ GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(
TRACE("%p, %d, %p\n", format, rangeCount, ranges);
new_ranges = heap_alloc_zero(rangeCount * sizeof(CharacterRange));
new_ranges = malloc(rangeCount * sizeof(CharacterRange));
if (!new_ranges)
return OutOfMemory;
heap_free(format->character_ranges);
free(format->character_ranges);
format->character_ranges = new_ranges;
memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount);
format->range_count = rangeCount;
......@@ -319,16 +319,9 @@ GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL fir
if(count > 0){
if(firsttab < 0.0) return NotImplemented;
/* first time allocation */
if(format->tabcount == 0){
format->tabs = heap_alloc_zero(sizeof(REAL)*count);
if(!format->tabs)
return OutOfMemory;
}
/* reallocation */
if((format->tabcount < count) && (format->tabcount > 0)){
if(format->tabcount < count){
REAL *ptr;
ptr = heap_realloc(format->tabs, sizeof(REAL)*count);
ptr = realloc(format->tabs, sizeof(REAL) * count);
if(!ptr)
return OutOfMemory;
format->tabs = ptr;
......@@ -371,15 +364,15 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
if(!format || !newFormat)
return InvalidParameter;
*newFormat = heap_alloc_zero(sizeof(GpStringFormat));
if(!*newFormat) return OutOfMemory;
*newFormat = malloc(sizeof(GpStringFormat));
if(!*newFormat) return OutOfMemory;
**newFormat = *format;
if(format->tabcount > 0){
(*newFormat)->tabs = heap_alloc_zero(sizeof(REAL) * format->tabcount);
(*newFormat)->tabs = malloc(sizeof(REAL) * format->tabcount);
if(!(*newFormat)->tabs){
heap_free(*newFormat);
free(*newFormat);
return OutOfMemory;
}
memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount);
......@@ -388,10 +381,10 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
(*newFormat)->tabs = NULL;
if(format->range_count > 0){
(*newFormat)->character_ranges = heap_alloc_zero(sizeof(CharacterRange) * format->range_count);
(*newFormat)->character_ranges = malloc(sizeof(CharacterRange) * format->range_count);
if(!(*newFormat)->character_ranges){
heap_free((*newFormat)->tabs);
heap_free(*newFormat);
free((*newFormat)->tabs);
free(*newFormat);
return OutOfMemory;
}
memcpy((*newFormat)->character_ranges, format->character_ranges,
......
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