Commit aa70a90c authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

gdiplus: Do not use GdipAlloc and GdipFree in internal functions.

parent d548639d
......@@ -38,18 +38,18 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
if(!from || !to)
return InvalidParameter;
*to = GdipAlloc(sizeof(GpCustomLineCap));
*to = heap_alloc_zero(sizeof(GpCustomLineCap));
if(!*to) return OutOfMemory;
memcpy(*to, from, sizeof(GpCustomLineCap));
(*to)->pathdata.Points = GdipAlloc(from->pathdata.Count * sizeof(PointF));
(*to)->pathdata.Types = GdipAlloc(from->pathdata.Count);
(*to)->pathdata.Points = heap_alloc_zero(from->pathdata.Count * sizeof(PointF));
(*to)->pathdata.Types = heap_alloc_zero(from->pathdata.Count);
if((!(*to)->pathdata.Types || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
GdipFree((*to)->pathdata.Points);
GdipFree((*to)->pathdata.Types);
GdipFree(*to);
heap_free((*to)->pathdata.Points);
heap_free((*to)->pathdata.Types);
heap_free(*to);
return OutOfMemory;
}
......@@ -74,7 +74,7 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
if(!customCap || !(fillPath || strokePath))
return InvalidParameter;
*customCap = GdipAlloc(sizeof(GpCustomLineCap));
*customCap = heap_alloc_zero(sizeof(GpCustomLineCap));
if(!*customCap) return OutOfMemory;
if(strokePath){
......@@ -86,14 +86,14 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
pathdata = &fillPath->pathdata;
}
(*customCap)->pathdata.Points = GdipAlloc(pathdata->Count * sizeof(PointF));
(*customCap)->pathdata.Types = GdipAlloc(pathdata->Count);
(*customCap)->pathdata.Points = heap_alloc_zero(pathdata->Count * sizeof(PointF));
(*customCap)->pathdata.Types = heap_alloc_zero(pathdata->Count);
if((!(*customCap)->pathdata.Types || !(*customCap)->pathdata.Points) &&
pathdata->Count){
GdipFree((*customCap)->pathdata.Points);
GdipFree((*customCap)->pathdata.Types);
GdipFree(*customCap);
heap_free((*customCap)->pathdata.Points);
heap_free((*customCap)->pathdata.Types);
heap_free(*customCap);
return OutOfMemory;
}
......@@ -119,9 +119,9 @@ GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
if(!customCap)
return InvalidParameter;
GdipFree(customCap->pathdata.Points);
GdipFree(customCap->pathdata.Types);
GdipFree(customCap);
heap_free(customCap->pathdata.Points);
heap_free(customCap->pathdata.Types);
heap_free(customCap);
return Ok;
}
......
......@@ -178,7 +178,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
if (!ret) return NotTrueTypeFont;
*font = GdipAlloc(sizeof(GpFont));
*font = heap_alloc_zero(sizeof(GpFont));
if (!*font) return OutOfMemory;
(*font)->unit = unit;
......@@ -188,7 +188,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
stat = clone_font_family(fontFamily, &(*font)->family);
if (stat != Ok)
{
GdipFree(*font);
heap_free(*font);
return stat;
}
......@@ -224,7 +224,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
if (!ret) return NotTrueTypeFont;
*font = GdipAlloc(sizeof(GpFont));
*font = heap_alloc_zero(sizeof(GpFont));
if (!*font) return OutOfMemory;
(*font)->unit = UnitWorld;
......@@ -234,7 +234,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family);
if (stat != Ok)
{
GdipFree(*font);
heap_free(*font);
return NotTrueTypeFont;
}
......@@ -275,7 +275,7 @@ GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
return InvalidParameter;
GdipDeleteFontFamily(font->family);
GdipFree(font);
heap_free(font);
return Ok;
}
......@@ -526,12 +526,12 @@ GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
if(!font || !cloneFont)
return InvalidParameter;
*cloneFont = GdipAlloc(sizeof(GpFont));
*cloneFont = heap_alloc_zero(sizeof(GpFont));
if(!*cloneFont) return OutOfMemory;
**cloneFont = *font;
stat = GdipCloneFontFamily(font->family, &(*cloneFont)->family);
if (stat != Ok) GdipFree(*cloneFont);
if (stat != Ok) heap_free(*cloneFont);
return stat;
}
......@@ -759,7 +759,7 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
stat = find_installed_font(name, &fm);
if (stat != Ok) return stat;
ffamily = GdipAlloc(sizeof (GpFontFamily));
ffamily = heap_alloc_zero(sizeof (GpFontFamily));
if (!ffamily) return OutOfMemory;
lstrcpyW(ffamily->FamilyName, fm.facename);
......@@ -778,7 +778,7 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
static GpStatus clone_font_family(const GpFontFamily *family, GpFontFamily **clone)
{
*clone = GdipAlloc(sizeof(GpFontFamily));
*clone = heap_alloc_zero(sizeof(GpFontFamily));
if (!*clone) return OutOfMemory;
**clone = *family;
......@@ -870,7 +870,7 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
return InvalidParameter;
TRACE("Deleting %p (%s)\n", FontFamily, debugstr_w(FontFamily->FamilyName));
GdipFree (FontFamily);
heap_free (FontFamily);
return Ok;
}
......@@ -1098,7 +1098,7 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti
if (!fontCollection)
return InvalidParameter;
*fontCollection = GdipAlloc(sizeof(GpFontCollection));
*fontCollection = heap_alloc_zero(sizeof(GpFontCollection));
if (!*fontCollection) return OutOfMemory;
(*fontCollection)->FontFamilies = NULL;
......@@ -1122,8 +1122,8 @@ GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontColle
if (!fontCollection)
return InvalidParameter;
for (i = 0; i < (*fontCollection)->count; i++) GdipFree((*fontCollection)->FontFamilies[i]);
GdipFree(*fontCollection);
for (i = 0; i < (*fontCollection)->count; i++) heap_free((*fontCollection)->FontFamilies[i]);
heap_free(*fontCollection);
return Ok;
}
......
......@@ -406,12 +406,12 @@ BOOL lengthen_path(GpPath *path, INT len)
if(path->datalen == 0){
path->datalen = len * 2;
path->pathdata.Points = GdipAlloc(path->datalen * sizeof(PointF));
path->pathdata.Points = heap_alloc_zero(path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = GdipAlloc(path->datalen);
path->pathdata.Types = heap_alloc_zero(path->datalen);
if(!path->pathdata.Types){
GdipFree(path->pathdata.Points);
heap_free(path->pathdata.Points);
return FALSE;
}
}
......@@ -467,8 +467,8 @@ void delete_element(region_element* element)
default:
delete_element(element->elementdata.combine.left);
delete_element(element->elementdata.combine.right);
GdipFree(element->elementdata.combine.left);
GdipFree(element->elementdata.combine.right);
heap_free(element->elementdata.combine.left);
heap_free(element->elementdata.combine.right);
break;
}
}
......
......@@ -48,6 +48,17 @@
#define GIF_DISPOSE_RESTORE_TO_BKGND 2
#define GIF_DISPOSE_RESTORE_TO_PREV 3
static void *heap_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1);
static inline void *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline BOOL heap_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
COLORREF ARGB2COLORREF(ARGB color) DECLSPEC_HIDDEN;
HBITMAP ARGB2BMP(ARGB color) DECLSPEC_HIDDEN;
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
......
......@@ -50,7 +50,7 @@ GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
if(!imageattr)
return InvalidParameter;
*imageattr = GdipAlloc(sizeof(GpImageAttributes));
*imageattr = heap_alloc_zero(sizeof(GpImageAttributes));
if(!*imageattr) return OutOfMemory;
(*imageattr)->wrap = WrapModeClamp;
......@@ -70,9 +70,9 @@ GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
return InvalidParameter;
for (i=0; i<ColorAdjustTypeCount; i++)
GdipFree(imageattr->colorremaptables[i].colormap);
heap_free(imageattr->colorremaptables[i].colormap);
GdipFree(imageattr);
heap_free(imageattr);
return Ok;
}
......@@ -222,21 +222,21 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
if(!map || !mapSize)
return InvalidParameter;
new_map = GdipAlloc(sizeof(*map) * mapSize);
new_map = heap_alloc_zero(sizeof(*map) * mapSize);
if (!new_map)
return OutOfMemory;
memcpy(new_map, map, sizeof(*map) * mapSize);
GdipFree(imageAttr->colorremaptables[type].colormap);
heap_free(imageAttr->colorremaptables[type].colormap);
imageAttr->colorremaptables[type].mapsize = mapSize;
imageAttr->colorremaptables[type].colormap = new_map;
}
else
{
GdipFree(imageAttr->colorremaptables[type].colormap);
heap_free(imageAttr->colorremaptables[type].colormap);
imageAttr->colorremaptables[type].colormap = NULL;
}
......
......@@ -66,7 +66,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22,
if(!matrix)
return InvalidParameter;
*matrix = GdipAlloc(sizeof(GpMatrix));
*matrix = heap_alloc_zero(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
/* first row */
......@@ -129,7 +129,7 @@ GpStatus WINGDIPAPI GdipCloneMatrix(GpMatrix *matrix, GpMatrix **clone)
if(!matrix || !clone)
return InvalidParameter;
*clone = GdipAlloc(sizeof(GpMatrix));
*clone = heap_alloc_zero(sizeof(GpMatrix));
if(!*clone) return OutOfMemory;
**clone = *matrix;
......@@ -144,7 +144,7 @@ GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
if(!matrix)
return InvalidParameter;
*matrix = GdipAlloc(sizeof(GpMatrix));
*matrix = heap_alloc_zero(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory;
(*matrix)->matrix[0] = 1.0;
......@@ -164,7 +164,7 @@ GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
if(!matrix)
return InvalidParameter;
GdipFree(matrix);
heap_free(matrix);
return Ok;
}
......@@ -380,7 +380,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
if(count <= 0)
return InvalidParameter;
ptsF = GdipAlloc(sizeof(GpPointF) * count);
ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
if(!ptsF)
return OutOfMemory;
......@@ -396,7 +396,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);
}
GdipFree(ptsF);
heap_free(ptsF);
return ret;
}
......@@ -461,7 +461,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
if(count <= 0)
return InvalidParameter;
ptsF = GdipAlloc(sizeof(GpPointF) * count);
ptsF = heap_alloc_zero(sizeof(GpPointF) * count);
if(!ptsF)
return OutOfMemory;
......@@ -477,7 +477,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
pts[i].X = gdip_round(ptsF[i].X);
pts[i].Y = gdip_round(ptsF[i].Y);
}
GdipFree(ptsF);
heap_free(ptsF);
return ret;
}
......@@ -513,7 +513,7 @@ GpStatus WINGDIPAPI GdipIsMatrixIdentity(GDIPCONST GpMatrix *matrix, BOOL *resul
if(ret == Ok)
*result = isIdentity;
GdipFree(e);
heap_free(e);
return ret;
}
......@@ -86,7 +86,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, DWORD size, void *
if (!metafile->comment_data_size)
{
DWORD data_size = max(256, size * 2 + 4);
metafile->comment_data = GdipAlloc(data_size);
metafile->comment_data = heap_alloc_zero(data_size);
if (!metafile->comment_data)
return OutOfMemory;
......@@ -102,7 +102,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, DWORD size, void *
if (size_needed > metafile->comment_data_size)
{
DWORD data_size = size_needed * 2;
BYTE *new_data = GdipAlloc(data_size);
BYTE *new_data = heap_alloc_zero(data_size);
if (!new_data)
return OutOfMemory;
......@@ -110,7 +110,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, DWORD size, void *
memcpy(new_data, metafile->comment_data, metafile->comment_data_length);
metafile->comment_data_size = data_size;
GdipFree(metafile->comment_data);
heap_free(metafile->comment_data);
metafile->comment_data = new_data;
}
......@@ -243,7 +243,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
if (!record_dc)
return GenericError;
*metafile = GdipAlloc(sizeof(GpMetafile));
*metafile = heap_alloc_zero(sizeof(GpMetafile));
if(!*metafile)
{
DeleteEnhMetaFile(CloseEnhMetaFile(record_dc));
......@@ -270,7 +270,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
if (stat != Ok)
{
DeleteEnhMetaFile(CloseEnhMetaFile(record_dc));
GdipFree(*metafile);
heap_free(*metafile);
*metafile = NULL;
return OutOfMemory;
}
......@@ -463,7 +463,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
metafile->hemf = CloseEnhMetaFile(metafile->record_dc);
metafile->record_dc = NULL;
GdipFree(metafile->comment_data);
heap_free(metafile->comment_data);
metafile->comment_data = NULL;
metafile->comment_data_size = 0;
......@@ -565,7 +565,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
{
ENHMETARECORD *record;
record = GdipAlloc(dataSize + 8);
record = heap_alloc_zero(dataSize + 8);
if (record)
{
......@@ -576,7 +576,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
PlayEnhMetaFileRecord(metafile->playback_dc, metafile->handle_table,
record, metafile->handle_count);
GdipFree(record);
heap_free(record);
}
else
return OutOfMemory;
......@@ -634,7 +634,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
EmfPlusRect *int_rects = (EmfPlusRect*)(record+1);
int i;
rects = temp_rects = GdipAlloc(sizeof(GpRectF) * record->Count);
rects = temp_rects = heap_alloc_zero(sizeof(GpRectF) * record->Count);
if (rects)
{
for (i=0; i<record->Count; i++)
......@@ -658,7 +658,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
}
GdipDeleteBrush(temp_brush);
GdipFree(temp_rects);
heap_free(temp_rects);
return stat;
}
......@@ -1010,7 +1010,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
if (metafile_type == MetafileTypeInvalid)
return GenericError;
*metafile = GdipAlloc(sizeof(GpMetafile));
*metafile = heap_alloc_zero(sizeof(GpMetafile));
if (!*metafile)
return OutOfMemory;
......@@ -1050,11 +1050,11 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
read = GetMetaFileBitsEx(hwmf, 0, NULL);
if(!read)
return GenericError;
copy = GdipAlloc(read);
copy = heap_alloc_zero(read);
GetMetaFileBitsEx(hwmf, read, copy);
hemf = SetWinMetaFileBits(read, copy, NULL, NULL);
GdipFree(copy);
heap_free(copy);
/* FIXME: We should store and use hwmf instead of converting to hemf */
retval = GdipCreateMetafileFromEmf(hemf, TRUE, metafile);
......
......@@ -40,14 +40,14 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
if(!iterator)
return InvalidParameter;
*iterator = GdipAlloc(sizeof(GpPathIterator));
*iterator = heap_alloc_zero(sizeof(GpPathIterator));
if(!*iterator) return OutOfMemory;
if(path){
size = path->pathdata.Count;
(*iterator)->pathdata.Types = GdipAlloc(size);
(*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
(*iterator)->pathdata.Types = heap_alloc_zero(size);
(*iterator)->pathdata.Points = heap_alloc_zero(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;
GdipFree(iter->pathdata.Types);
GdipFree(iter->pathdata.Points);
GdipFree(iter);
heap_free(iter->pathdata.Types);
heap_free(iter->pathdata.Points);
heap_free(iter);
return Ok;
}
......
......@@ -94,7 +94,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if(!pen || !clonepen)
return InvalidParameter;
*clonepen = GdipAlloc(sizeof(GpPen));
*clonepen = heap_alloc_zero(sizeof(GpPen));
if(!*clonepen) return OutOfMemory;
**clonepen = *pen;
......@@ -114,7 +114,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if (stat == Ok && pen->dashes)
{
(*clonepen)->dashes = GdipAlloc(pen->numdashes * sizeof(REAL));
(*clonepen)->dashes = heap_alloc_zero(pen->numdashes * sizeof(REAL));
if ((*clonepen)->dashes)
memcpy((*clonepen)->dashes, pen->dashes, pen->numdashes * sizeof(REAL));
else
......@@ -158,7 +158,7 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
if(!pen || !brush)
return InvalidParameter;
gp_pen = GdipAlloc(sizeof(GpPen));
gp_pen = heap_alloc_zero(sizeof(GpPen));
if(!gp_pen) return OutOfMemory;
gp_pen->style = GP_DEFAULT_PENSTYLE;
......@@ -174,7 +174,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");
GdipFree(gp_pen);
heap_free(gp_pen);
return NotImplemented;
}
......@@ -197,8 +197,8 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
GdipDeleteBrush(pen->brush);
GdipDeleteCustomLineCap(pen->customstart);
GdipDeleteCustomLineCap(pen->customend);
GdipFree(pen->dashes);
GdipFree(pen);
heap_free(pen->dashes);
heap_free(pen);
return Ok;
}
......@@ -628,11 +628,11 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
if(sum == 0.0 && count)
return InvalidParameter;
GdipFree(pen->dashes);
heap_free(pen->dashes);
pen->dashes = NULL;
if(count > 0)
pen->dashes = GdipAlloc(count * sizeof(REAL));
pen->dashes = heap_alloc_zero(count * sizeof(REAL));
if(!pen->dashes){
pen->numdashes = 0;
return OutOfMemory;
......@@ -678,7 +678,7 @@ GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
return InvalidParameter;
if(dash != DashStyleCustom){
GdipFree(pen->dashes);
heap_free(pen->dashes);
pen->dashes = NULL;
pen->numdashes = 0;
}
......
......@@ -189,7 +189,7 @@ static inline GpStatus clone_element(const region_element* element,
/* root node is allocated with GpRegion */
if(!*element2){
*element2 = GdipAlloc(sizeof(region_element));
*element2 = heap_alloc_zero(sizeof(region_element));
if (!*element2)
return OutOfMemory;
}
......@@ -262,7 +262,7 @@ GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
if (!(region && clone))
return InvalidParameter;
*clone = GdipAlloc(sizeof(GpRegion));
*clone = heap_alloc_zero(sizeof(GpRegion));
if (!*clone)
return OutOfMemory;
element = &(*clone)->node;
......@@ -293,11 +293,11 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, path_region, sizeof(GpRegion));
GdipFree(path_region);
heap_free(path_region);
return Ok;
}
left = GdipAlloc(sizeof(region_element));
left = heap_alloc_zero(sizeof(region_element));
if (left)
{
*left = region->node;
......@@ -312,7 +312,7 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
else
stat = OutOfMemory;
GdipFree(left);
heap_free(left);
GdipDeleteRegion(path_region);
return stat;
}
......@@ -340,11 +340,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
if(mode == CombineModeReplace){
delete_element(&region->node);
memcpy(region, rect_region, sizeof(GpRegion));
GdipFree(rect_region);
heap_free(rect_region);
return Ok;
}
left = GdipAlloc(sizeof(region_element));
left = heap_alloc_zero(sizeof(region_element));
if (left)
{
memcpy(left, &region->node, sizeof(region_element));
......@@ -359,7 +359,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
else
stat = OutOfMemory;
GdipFree(left);
heap_free(left);
GdipDeleteRegion(rect_region);
return stat;
}
......@@ -407,11 +407,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
delete_element(&region1->node);
memcpy(region1, reg2copy, sizeof(GpRegion));
GdipFree(reg2copy);
heap_free(reg2copy);
return Ok;
}
left = GdipAlloc(sizeof(region_element));
left = heap_alloc_zero(sizeof(region_element));
if (!left)
return OutOfMemory;
......@@ -419,7 +419,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
stat = clone_element(&region2->node, &right);
if (stat != Ok)
{
GdipFree(left);
heap_free(left);
return OutOfMemory;
}
......@@ -439,7 +439,7 @@ GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
if(!region)
return InvalidParameter;
*region = GdipAlloc(sizeof(GpRegion));
*region = heap_alloc_zero(sizeof(GpRegion));
if(!*region)
return OutOfMemory;
......@@ -477,7 +477,7 @@ GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
if (!(path && region))
return InvalidParameter;
*region = GdipAlloc(sizeof(GpRegion));
*region = heap_alloc_zero(sizeof(GpRegion));
if(!*region)
return OutOfMemory;
stat = init_region(*region, RegionDataPath);
......@@ -511,7 +511,7 @@ GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
if (!(rect && region))
return InvalidParameter;
*region = GdipAlloc(sizeof(GpRegion));
*region = heap_alloc_zero(sizeof(GpRegion));
stat = init_region(*region, RegionDataRect);
if(stat != Ok)
{
......@@ -563,32 +563,32 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
if(!region || !(size = GetRegionData(hrgn, 0, NULL)))
return InvalidParameter;
buf = GdipAlloc(size);
buf = heap_alloc_zero(size);
if(!buf)
return OutOfMemory;
if(!GetRegionData(hrgn, size, buf)){
GdipFree(buf);
heap_free(buf);
return GenericError;
}
if(buf->rdh.nCount == 0){
if((stat = GdipCreateRegion(&local)) != Ok){
GdipFree(buf);
heap_free(buf);
return stat;
}
if((stat = GdipSetEmpty(local)) != Ok){
GdipFree(buf);
heap_free(buf);
GdipDeleteRegion(local);
return stat;
}
*region = local;
GdipFree(buf);
heap_free(buf);
return Ok;
}
if((stat = GdipCreatePath(FillModeAlternate, &path)) != Ok){
GdipFree(buf);
heap_free(buf);
return stat;
}
......@@ -596,7 +596,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){
GdipFree(buf);
heap_free(buf);
GdipDeletePath(path);
return stat;
}
......@@ -605,7 +605,7 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
stat = GdipCreateRegionPath(path, region);
GdipFree(buf);
heap_free(buf);
GdipDeletePath(path);
return stat;
}
......@@ -621,7 +621,7 @@ GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
return InvalidParameter;
delete_element(&region->node);
GdipFree(region);
heap_free(region);
return Ok;
}
......@@ -906,12 +906,12 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
{
region_element *left, *right;
left = GdipAlloc(sizeof(region_element));
left = heap_alloc_zero(sizeof(region_element));
if (!left) return OutOfMemory;
right = GdipAlloc(sizeof(region_element));
right = heap_alloc_zero(sizeof(region_element));
if (!right)
{
GdipFree(left);
heap_free(left);
return OutOfMemory;
}
......@@ -928,8 +928,8 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
}
}
GdipFree(left);
GdipFree(right);
heap_free(left);
heap_free(right);
return status;
}
......@@ -1525,7 +1525,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));
GdipFree(new_region);
heap_free(new_region);
}
else
return stat;
......@@ -1631,7 +1631,7 @@ static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGND
{
data_size = GetRegionData(hrgn, 0, NULL);
*data = GdipAlloc(data_size);
*data = heap_alloc_zero(data_size);
if (*data)
GetRegionData(hrgn, data_size, *data);
......@@ -1644,7 +1644,7 @@ static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGND
{
data_size = sizeof(RGNDATAHEADER) + sizeof(RECT);
*data = GdipAlloc(data_size);
*data = heap_alloc_zero(data_size);
if (*data)
{
......@@ -1683,7 +1683,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMat
if (stat == Ok)
{
*count = data->rdh.nCount;
GdipFree(data);
heap_free(data);
}
return stat;
......@@ -1717,7 +1717,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *co
}
}
GdipFree(data);
heap_free(data);
}
return Ok;
......@@ -1751,7 +1751,7 @@ GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *co
}
}
GdipFree(data);
heap_free(data);
}
return Ok;
......
......@@ -40,7 +40,7 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
if(!format)
return InvalidParameter;
*format = GdipAlloc(sizeof(GpStringFormat));
*format = heap_alloc_zero(sizeof(GpStringFormat));
if(!*format) return OutOfMemory;
(*format)->attr = attr;
......@@ -66,9 +66,9 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
if(!format)
return InvalidParameter;
GdipFree(format->character_ranges);
GdipFree(format->tabs);
GdipFree(format);
heap_free(format->character_ranges);
heap_free(format->tabs);
heap_free(format);
return Ok;
}
......@@ -260,11 +260,11 @@ GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(
TRACE("%p, %d, %p\n", format, rangeCount, ranges);
new_ranges = GdipAlloc(rangeCount * sizeof(CharacterRange));
new_ranges = heap_alloc_zero(rangeCount * sizeof(CharacterRange));
if (!new_ranges)
return OutOfMemory;
GdipFree(format->character_ranges);
heap_free(format->character_ranges);
format->character_ranges = new_ranges;
memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount);
format->range_count = rangeCount;
......@@ -284,7 +284,7 @@ GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL fir
if(firsttab < 0.0) return NotImplemented;
/* first time allocation */
if(format->tabcount == 0){
format->tabs = GdipAlloc(sizeof(REAL)*count);
format->tabs = heap_alloc_zero(sizeof(REAL)*count);
if(!format->tabs)
return OutOfMemory;
}
......@@ -334,15 +334,15 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
if(!format || !newFormat)
return InvalidParameter;
*newFormat = GdipAlloc(sizeof(GpStringFormat));
*newFormat = heap_alloc_zero(sizeof(GpStringFormat));
if(!*newFormat) return OutOfMemory;
**newFormat = *format;
if(format->tabcount > 0){
(*newFormat)->tabs = GdipAlloc(sizeof(REAL) * format->tabcount);
(*newFormat)->tabs = heap_alloc_zero(sizeof(REAL) * format->tabcount);
if(!(*newFormat)->tabs){
GdipFree(*newFormat);
heap_free(*newFormat);
return OutOfMemory;
}
memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount);
......@@ -351,10 +351,10 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
(*newFormat)->tabs = NULL;
if(format->range_count > 0){
(*newFormat)->character_ranges = GdipAlloc(sizeof(CharacterRange) * format->range_count);
(*newFormat)->character_ranges = heap_alloc_zero(sizeof(CharacterRange) * format->range_count);
if(!(*newFormat)->character_ranges){
GdipFree((*newFormat)->tabs);
GdipFree(*newFormat);
heap_free((*newFormat)->tabs);
heap_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