1
0
Fork 0
mirror of synced 2025-03-07 03:53:26 +01:00

gdiplus: Use CRT allocation functions.

This commit is contained in:
Alex Henrie 2023-11-29 09:18:48 -07:00 committed by Alexandre Julliard
parent a3f4878f52
commit 69d815407d
15 changed files with 530 additions and 538 deletions

View file

@ -48,7 +48,7 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
switch(brush->bt){ switch(brush->bt){
case BrushTypeSolidColor: case BrushTypeSolidColor:
{ {
*clone = heap_alloc_zero(sizeof(GpSolidFill)); *clone = malloc(sizeof(GpSolidFill));
if (!*clone) return OutOfMemory; if (!*clone) return OutOfMemory;
memcpy(*clone, brush, sizeof(GpSolidFill)); memcpy(*clone, brush, sizeof(GpSolidFill));
break; break;
@ -64,7 +64,7 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
INT count, pcount; INT count, pcount;
GpStatus stat; GpStatus stat;
*clone = heap_alloc_zero(sizeof(GpPathGradient)); *clone = malloc(sizeof(GpPathGradient));
if (!*clone) return OutOfMemory; if (!*clone) return OutOfMemory;
src = (GpPathGradient*) brush; src = (GpPathGradient*) brush;
@ -75,7 +75,7 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
stat = GdipClonePath(src->path, &dest->path); stat = GdipClonePath(src->path, &dest->path);
if(stat != Ok){ if(stat != Ok){
heap_free(dest); free(dest);
return stat; return stat;
} }
@ -84,25 +84,25 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
/* blending */ /* blending */
count = src->blendcount; count = src->blendcount;
dest->blendcount = count; dest->blendcount = count;
dest->blendfac = heap_alloc_zero(count * sizeof(REAL)); dest->blendfac = malloc(count * sizeof(REAL));
dest->blendpos = heap_alloc_zero(count * sizeof(REAL)); dest->blendpos = malloc(count * sizeof(REAL));
dest->surroundcolors = heap_alloc_zero(dest->surroundcolorcount * sizeof(ARGB)); dest->surroundcolors = malloc(dest->surroundcolorcount * sizeof(ARGB));
pcount = dest->pblendcount; pcount = dest->pblendcount;
if (pcount) if (pcount)
{ {
dest->pblendcolor = heap_alloc_zero(pcount * sizeof(ARGB)); dest->pblendcolor = malloc(pcount * sizeof(ARGB));
dest->pblendpos = heap_alloc_zero(pcount * sizeof(REAL)); dest->pblendpos = malloc(pcount * sizeof(REAL));
} }
if(!dest->blendfac || !dest->blendpos || !dest->surroundcolors || if(!dest->blendfac || !dest->blendpos || !dest->surroundcolors ||
(pcount && (!dest->pblendcolor || !dest->pblendpos))){ (pcount && (!dest->pblendcolor || !dest->pblendpos))){
GdipDeletePath(dest->path); GdipDeletePath(dest->path);
heap_free(dest->blendfac); free(dest->blendfac);
heap_free(dest->blendpos); free(dest->blendpos);
heap_free(dest->surroundcolors); free(dest->surroundcolors);
heap_free(dest->pblendcolor); free(dest->pblendcolor);
heap_free(dest->pblendpos); free(dest->pblendpos);
heap_free(dest); free(dest);
return OutOfMemory; return OutOfMemory;
} }
@ -122,31 +122,31 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
GpLineGradient *dest, *src; GpLineGradient *dest, *src;
INT count, pcount; INT count, pcount;
dest = heap_alloc_zero(sizeof(GpLineGradient)); dest = malloc(sizeof(GpLineGradient));
if(!dest) return OutOfMemory; if(!dest) return OutOfMemory;
src = (GpLineGradient*)brush; src = (GpLineGradient*)brush;
memcpy(dest, src, sizeof(GpLineGradient)); memcpy(dest, src, sizeof(GpLineGradient));
count = dest->blendcount; count = dest->blendcount;
dest->blendfac = heap_alloc_zero(count * sizeof(REAL)); dest->blendfac = malloc(count * sizeof(REAL));
dest->blendpos = heap_alloc_zero(count * sizeof(REAL)); dest->blendpos = malloc(count * sizeof(REAL));
pcount = dest->pblendcount; pcount = dest->pblendcount;
if (pcount) if (pcount)
{ {
dest->pblendcolor = heap_alloc_zero(pcount * sizeof(ARGB)); dest->pblendcolor = malloc(pcount * sizeof(ARGB));
dest->pblendpos = heap_alloc_zero(pcount * sizeof(REAL)); dest->pblendpos = malloc(pcount * sizeof(REAL));
} }
if (!dest->blendfac || !dest->blendpos || if (!dest->blendfac || !dest->blendpos ||
(pcount && (!dest->pblendcolor || !dest->pblendpos))) (pcount && (!dest->pblendcolor || !dest->pblendpos)))
{ {
heap_free(dest->blendfac); free(dest->blendfac);
heap_free(dest->blendpos); free(dest->blendpos);
heap_free(dest->pblendcolor); free(dest->pblendcolor);
heap_free(dest->pblendpos); free(dest->pblendpos);
heap_free(dest); free(dest);
return OutOfMemory; return OutOfMemory;
} }
@ -278,7 +278,7 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol,
if(hatchstyle < HatchStyleMin || hatchstyle > HatchStyleMax) if(hatchstyle < HatchStyleMin || hatchstyle > HatchStyleMax)
return InvalidParameter; return InvalidParameter;
*brush = heap_alloc_zero(sizeof(GpHatch)); *brush = calloc(1, sizeof(GpHatch));
if (!*brush) return OutOfMemory; if (!*brush) return OutOfMemory;
(*brush)->brush.bt = BrushTypeHatchFill; (*brush)->brush.bt = BrushTypeHatchFill;
@ -293,7 +293,7 @@ GpStatus WINGDIPAPI GdipCreateHatchBrush(GpHatchStyle hatchstyle, ARGB forecol,
static GpStatus create_line_brush(const GpRectF *rect, ARGB startcolor, ARGB endcolor, static GpStatus create_line_brush(const GpRectF *rect, ARGB startcolor, ARGB endcolor,
GpWrapMode wrap, GpLineGradient **line) GpWrapMode wrap, GpLineGradient **line)
{ {
*line = heap_alloc_zero(sizeof(GpLineGradient)); *line = calloc(1, sizeof(GpLineGradient));
if(!*line) return OutOfMemory; if(!*line) return OutOfMemory;
(*line)->brush.bt = BrushTypeLinearGradient; (*line)->brush.bt = BrushTypeLinearGradient;
@ -303,14 +303,14 @@ static GpStatus create_line_brush(const GpRectF *rect, ARGB startcolor, ARGB end
(*line)->gamma = FALSE; (*line)->gamma = FALSE;
(*line)->rect = *rect; (*line)->rect = *rect;
(*line)->blendcount = 1; (*line)->blendcount = 1;
(*line)->blendfac = heap_alloc_zero(sizeof(REAL)); (*line)->blendfac = malloc(sizeof(REAL));
(*line)->blendpos = heap_alloc_zero(sizeof(REAL)); (*line)->blendpos = malloc(sizeof(REAL));
if (!(*line)->blendfac || !(*line)->blendpos) if (!(*line)->blendfac || !(*line)->blendpos)
{ {
heap_free((*line)->blendfac); free((*line)->blendfac);
heap_free((*line)->blendpos); free((*line)->blendpos);
heap_free(*line); free(*line);
*line = NULL; *line = NULL;
return OutOfMemory; return OutOfMemory;
} }
@ -604,7 +604,7 @@ static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradi
if (path->pathdata.Count < 2) if (path->pathdata.Count < 2)
return OutOfMemory; return OutOfMemory;
*grad = heap_alloc_zero(sizeof(GpPathGradient)); *grad = calloc(1, sizeof(GpPathGradient));
if (!*grad) if (!*grad)
{ {
return OutOfMemory; return OutOfMemory;
@ -612,14 +612,14 @@ static GpStatus create_path_gradient(GpPath *path, ARGB centercolor, GpPathGradi
GdipSetMatrixElements(&(*grad)->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); GdipSetMatrixElements(&(*grad)->transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
(*grad)->blendfac = heap_alloc_zero(sizeof(REAL)); (*grad)->blendfac = malloc(sizeof(REAL));
(*grad)->blendpos = heap_alloc_zero(sizeof(REAL)); (*grad)->blendpos = malloc(sizeof(REAL));
(*grad)->surroundcolors = heap_alloc_zero(sizeof(ARGB)); (*grad)->surroundcolors = malloc(sizeof(ARGB));
if(!(*grad)->blendfac || !(*grad)->blendpos || !(*grad)->surroundcolors){ if(!(*grad)->blendfac || !(*grad)->blendpos || !(*grad)->surroundcolors){
heap_free((*grad)->blendfac); free((*grad)->blendfac);
heap_free((*grad)->blendpos); free((*grad)->blendpos);
heap_free((*grad)->surroundcolors); free((*grad)->surroundcolors);
heap_free(*grad); free(*grad);
*grad = NULL; *grad = NULL;
return OutOfMemory; return OutOfMemory;
} }
@ -756,7 +756,7 @@ GpStatus WINGDIPAPI GdipCreateSolidFill(ARGB color, GpSolidFill **sf)
if(!sf) return InvalidParameter; if(!sf) return InvalidParameter;
*sf = heap_alloc_zero(sizeof(GpSolidFill)); *sf = calloc(1, sizeof(GpSolidFill));
if (!*sf) return OutOfMemory; if (!*sf) return OutOfMemory;
(*sf)->brush.bt = BrushTypeSolidColor; (*sf)->brush.bt = BrushTypeSolidColor;
@ -865,7 +865,7 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
if (status != Ok) if (status != Ok)
return status; return status;
*texture = heap_alloc_zero(sizeof(GpTexture)); *texture = calloc(1, sizeof(GpTexture));
if (!*texture){ if (!*texture){
status = OutOfMemory; status = OutOfMemory;
goto exit; goto exit;
@ -899,7 +899,7 @@ exit:
if (*texture) if (*texture)
{ {
GdipDisposeImageAttributes((*texture)->imageattributes); GdipDisposeImageAttributes((*texture)->imageattributes);
heap_free(*texture); free(*texture);
*texture = NULL; *texture = NULL;
} }
GdipDisposeImage(new_image); GdipDisposeImage(new_image);
@ -996,29 +996,29 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
switch(brush->bt) switch(brush->bt)
{ {
case BrushTypePathGradient: case BrushTypePathGradient:
GdipDeletePath(((GpPathGradient*) brush)->path); GdipDeletePath(((GpPathGradient*)brush)->path);
heap_free(((GpPathGradient*) brush)->blendfac); free(((GpPathGradient*)brush)->blendfac);
heap_free(((GpPathGradient*) brush)->blendpos); free(((GpPathGradient*)brush)->blendpos);
heap_free(((GpPathGradient*) brush)->surroundcolors); free(((GpPathGradient*)brush)->surroundcolors);
heap_free(((GpPathGradient*) brush)->pblendcolor); free(((GpPathGradient*)brush)->pblendcolor);
heap_free(((GpPathGradient*) brush)->pblendpos); free(((GpPathGradient*)brush)->pblendpos);
break; break;
case BrushTypeLinearGradient: case BrushTypeLinearGradient:
heap_free(((GpLineGradient*)brush)->blendfac); free(((GpLineGradient*)brush)->blendfac);
heap_free(((GpLineGradient*)brush)->blendpos); free(((GpLineGradient*)brush)->blendpos);
heap_free(((GpLineGradient*)brush)->pblendcolor); free(((GpLineGradient*)brush)->pblendcolor);
heap_free(((GpLineGradient*)brush)->pblendpos); free(((GpLineGradient*)brush)->pblendpos);
break; break;
case BrushTypeTextureFill: case BrushTypeTextureFill:
GdipDisposeImage(((GpTexture*)brush)->image); GdipDisposeImage(((GpTexture*)brush)->image);
GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes); GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
heap_free(((GpTexture*)brush)->bitmap_bits); free(((GpTexture*)brush)->bitmap_bits);
break; break;
default: default:
break; break;
} }
heap_free(brush); free(brush);
return Ok; return Ok;
} }
@ -1373,21 +1373,21 @@ GpStatus WINGDIPAPI GdipSetLineBlend(GpLineGradient *brush,
(count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f))) (count >= 2 && (positions[0] != 0.0f || positions[count-1] != 1.0f)))
return InvalidParameter; return InvalidParameter;
new_blendfac = heap_alloc_zero(count * sizeof(REAL)); new_blendfac = malloc(count * sizeof(REAL));
new_blendpos = heap_alloc_zero(count * sizeof(REAL)); new_blendpos = malloc(count * sizeof(REAL));
if (!new_blendfac || !new_blendpos) if (!new_blendfac || !new_blendpos)
{ {
heap_free(new_blendfac); free(new_blendfac);
heap_free(new_blendpos); free(new_blendpos);
return OutOfMemory; return OutOfMemory;
} }
memcpy(new_blendfac, factors, count * sizeof(REAL)); memcpy(new_blendfac, factors, count * sizeof(REAL));
memcpy(new_blendpos, positions, count * sizeof(REAL)); memcpy(new_blendpos, positions, count * sizeof(REAL));
heap_free(brush->blendfac); free(brush->blendfac);
heap_free(brush->blendpos); free(brush->blendpos);
brush->blendcount = count; brush->blendcount = count;
brush->blendfac = new_blendfac; brush->blendfac = new_blendfac;
@ -1518,21 +1518,21 @@ GpStatus WINGDIPAPI GdipSetPathGradientBlend(GpPathGradient *brush, GDIPCONST RE
(count >= 2 && (pos[0] != 0.0f || pos[count-1] != 1.0f))) (count >= 2 && (pos[0] != 0.0f || pos[count-1] != 1.0f)))
return InvalidParameter; return InvalidParameter;
new_blendfac = heap_alloc_zero(count * sizeof(REAL)); new_blendfac = malloc(count * sizeof(REAL));
new_blendpos = heap_alloc_zero(count * sizeof(REAL)); new_blendpos = malloc(count * sizeof(REAL));
if (!new_blendfac || !new_blendpos) if (!new_blendfac || !new_blendpos)
{ {
heap_free(new_blendfac); free(new_blendfac);
heap_free(new_blendpos); free(new_blendpos);
return OutOfMemory; return OutOfMemory;
} }
memcpy(new_blendfac, blend, count * sizeof(REAL)); memcpy(new_blendfac, blend, count * sizeof(REAL));
memcpy(new_blendpos, pos, count * sizeof(REAL)); memcpy(new_blendpos, pos, count * sizeof(REAL));
heap_free(brush->blendfac); free(brush->blendfac);
heap_free(brush->blendpos); free(brush->blendpos);
brush->blendcount = count; brush->blendcount = count;
brush->blendfac = new_blendfac; brush->blendfac = new_blendfac;
@ -1587,20 +1587,20 @@ GpStatus WINGDIPAPI GdipSetPathGradientPresetBlend(GpPathGradient *brush,
return InvalidParameter; return InvalidParameter;
} }
new_color = heap_alloc_zero(count * sizeof(ARGB)); new_color = malloc(count * sizeof(ARGB));
new_pos = heap_alloc_zero(count * sizeof(REAL)); new_pos = malloc(count * sizeof(REAL));
if (!new_color || !new_pos) if (!new_color || !new_pos)
{ {
heap_free(new_color); free(new_color);
heap_free(new_pos); free(new_pos);
return OutOfMemory; return OutOfMemory;
} }
memcpy(new_color, blend, sizeof(ARGB) * count); memcpy(new_color, blend, sizeof(ARGB) * count);
memcpy(new_pos, pos, sizeof(REAL) * count); memcpy(new_pos, pos, sizeof(REAL) * count);
heap_free(brush->pblendcolor); free(brush->pblendcolor);
heap_free(brush->pblendpos); free(brush->pblendpos);
brush->pblendcolor = new_color; brush->pblendcolor = new_color;
brush->pblendpos = new_pos; brush->pblendpos = new_pos;
@ -1811,13 +1811,13 @@ GpStatus WINGDIPAPI GdipSetPathGradientSurroundColorsWithCount(GpPathGradient
num_colors = 1; num_colors = 1;
} }
new_surroundcolors = heap_alloc_zero(num_colors * sizeof(ARGB)); new_surroundcolors = malloc(num_colors * sizeof(ARGB));
if (!new_surroundcolors) if (!new_surroundcolors)
return OutOfMemory; return OutOfMemory;
memcpy(new_surroundcolors, argb, num_colors * sizeof(ARGB)); memcpy(new_surroundcolors, argb, num_colors * sizeof(ARGB));
heap_free(grad->surroundcolors); free(grad->surroundcolors);
grad->surroundcolors = new_surroundcolors; grad->surroundcolors = new_surroundcolors;
grad->surroundcolorcount = num_colors; grad->surroundcolorcount = num_colors;
@ -2048,20 +2048,20 @@ GpStatus WINGDIPAPI GdipSetLinePresetBlend(GpLineGradient *brush,
return InvalidParameter; return InvalidParameter;
} }
new_color = heap_alloc_zero(count * sizeof(ARGB)); new_color = malloc(count * sizeof(ARGB));
new_pos = heap_alloc_zero(count * sizeof(REAL)); new_pos = malloc(count * sizeof(REAL));
if (!new_color || !new_pos) if (!new_color || !new_pos)
{ {
heap_free(new_color); free(new_color);
heap_free(new_pos); free(new_pos);
return OutOfMemory; return OutOfMemory;
} }
memcpy(new_color, blend, sizeof(ARGB) * count); memcpy(new_color, blend, sizeof(ARGB) * count);
memcpy(new_pos, positions, sizeof(REAL) * count); memcpy(new_pos, positions, sizeof(REAL) * count);
heap_free(brush->pblendcolor); free(brush->pblendcolor);
heap_free(brush->pblendpos); free(brush->pblendpos);
brush->pblendcolor = new_color; brush->pblendcolor = new_color;
brush->pblendpos = new_pos; brush->pblendpos = new_pos;

View file

@ -40,9 +40,9 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
return InvalidParameter; return InvalidParameter;
if (from->type == CustomLineCapTypeDefault) if (from->type == CustomLineCapTypeDefault)
*to = heap_alloc_zero(sizeof(GpCustomLineCap)); *to = malloc(sizeof(GpCustomLineCap));
else else
*to = heap_alloc_zero(sizeof(GpAdjustableArrowCap)); *to = malloc(sizeof(GpAdjustableArrowCap));
if (!*to) if (!*to)
return OutOfMemory; return OutOfMemory;
@ -53,13 +53,13 @@ GpStatus WINGDIPAPI GdipCloneCustomLineCap(GpCustomLineCap* from,
*(GpAdjustableArrowCap *)*to = *(GpAdjustableArrowCap *)from; *(GpAdjustableArrowCap *)*to = *(GpAdjustableArrowCap *)from;
/* Duplicate path data */ /* Duplicate path data */
(*to)->pathdata.Points = heap_alloc_zero(from->pathdata.Count * sizeof(PointF)); (*to)->pathdata.Points = malloc(from->pathdata.Count * sizeof(PointF));
(*to)->pathdata.Types = heap_alloc_zero(from->pathdata.Count); (*to)->pathdata.Types = malloc(from->pathdata.Count);
if((!(*to)->pathdata.Types || !(*to)->pathdata.Points) && (*to)->pathdata.Count){ if((!(*to)->pathdata.Types || !(*to)->pathdata.Points) && (*to)->pathdata.Count){
heap_free((*to)->pathdata.Points); free((*to)->pathdata.Points);
heap_free((*to)->pathdata.Types); free((*to)->pathdata.Types);
heap_free(*to); free(*to);
return OutOfMemory; return OutOfMemory;
} }
@ -77,13 +77,13 @@ static GpStatus init_custom_linecap(GpCustomLineCap *cap, GpPathData *pathdata,
{ {
cap->fill = fill; cap->fill = fill;
cap->pathdata.Points = heap_alloc_zero(pathdata->Count * sizeof(PointF)); cap->pathdata.Points = malloc(pathdata->Count * sizeof(PointF));
cap->pathdata.Types = heap_alloc_zero(pathdata->Count); cap->pathdata.Types = malloc(pathdata->Count);
if ((!cap->pathdata.Types || !cap->pathdata.Points) && pathdata->Count) if ((!cap->pathdata.Types || !cap->pathdata.Points) && pathdata->Count)
{ {
heap_free(cap->pathdata.Points); free(cap->pathdata.Points);
heap_free(cap->pathdata.Types); free(cap->pathdata.Types);
cap->pathdata.Points = NULL; cap->pathdata.Points = NULL;
cap->pathdata.Types = NULL; cap->pathdata.Types = NULL;
return OutOfMemory; return OutOfMemory;
@ -119,8 +119,8 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
if(!customCap || !(fillPath || strokePath)) if(!customCap || !(fillPath || strokePath))
return InvalidParameter; return InvalidParameter;
*customCap = heap_alloc_zero(sizeof(GpCustomLineCap)); *customCap = calloc(1, sizeof(GpCustomLineCap));
if(!*customCap) return OutOfMemory; if(!*customCap) return OutOfMemory;
if (strokePath) if (strokePath)
pathdata = &strokePath->pathdata; pathdata = &strokePath->pathdata;
@ -130,7 +130,7 @@ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath
stat = init_custom_linecap(*customCap, pathdata, fillPath != NULL, baseCap, baseInset); stat = init_custom_linecap(*customCap, pathdata, fillPath != NULL, baseCap, baseInset);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(*customCap); free(*customCap);
return stat; return stat;
} }
@ -146,9 +146,9 @@ GpStatus WINGDIPAPI GdipDeleteCustomLineCap(GpCustomLineCap *customCap)
if(!customCap) if(!customCap)
return InvalidParameter; return InvalidParameter;
heap_free(customCap->pathdata.Points); free(customCap->pathdata.Points);
heap_free(customCap->pathdata.Types); free(customCap->pathdata.Types);
heap_free(customCap); free(customCap);
return Ok; return Ok;
} }
@ -337,7 +337,7 @@ GpStatus WINGDIPAPI GdipCreateAdjustableArrowCap(REAL height, REAL width, BOOL f
if (!cap) if (!cap)
return InvalidParameter; return InvalidParameter;
*cap = heap_alloc_zero(sizeof(**cap)); *cap = calloc(1, sizeof(**cap));
if (!*cap) if (!*cap)
return OutOfMemory; 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); stat = init_custom_linecap(&(*cap)->cap, &pathdata, fill, LineCapTriangle, width != 0.0 ? height / width : 0.0);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(*cap); free(*cap);
return stat; return stat;
} }

View file

@ -185,7 +185,7 @@ GpStatus WINGDIPAPI GdipCreateFont(GDIPCONST GpFontFamily *fontFamily,
if (!ret) return NotTrueTypeFont; if (!ret) return NotTrueTypeFont;
*font = heap_alloc_zero(sizeof(GpFont)); *font = calloc(1, sizeof(GpFont));
if (!*font) return OutOfMemory; if (!*font) return OutOfMemory;
(*font)->unit = unit; (*font)->unit = unit;
@ -225,7 +225,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
if (!ret) return NotTrueTypeFont; if (!ret) return NotTrueTypeFont;
*font = heap_alloc_zero(sizeof(GpFont)); *font = calloc(1, sizeof(GpFont));
if (!*font) return OutOfMemory; if (!*font) return OutOfMemory;
(*font)->unit = UnitWorld; (*font)->unit = UnitWorld;
@ -235,7 +235,7 @@ GpStatus WINGDIPAPI GdipCreateFontFromLogfontW(HDC hdc,
stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family); stat = GdipCreateFontFamilyFromName(facename, NULL, &(*font)->family);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(*font); free(*font);
return NotTrueTypeFont; return NotTrueTypeFont;
} }
@ -276,7 +276,7 @@ GpStatus WINGDIPAPI GdipDeleteFont(GpFont* font)
return InvalidParameter; return InvalidParameter;
GdipDeleteFontFamily(font->family); GdipDeleteFontFamily(font->family);
heap_free(font); free(font);
return Ok; return Ok;
} }
@ -506,8 +506,8 @@ GpStatus WINGDIPAPI GdipCloneFont(GpFont *font, GpFont **cloneFont)
if(!font || !cloneFont) if(!font || !cloneFont)
return InvalidParameter; return InvalidParameter;
*cloneFont = heap_alloc_zero(sizeof(GpFont)); *cloneFont = calloc(1, sizeof(GpFont));
if(!*cloneFont) return OutOfMemory; if(!*cloneFont) return OutOfMemory;
**cloneFont = *font; **cloneFont = *font;
return Ok; return Ok;
@ -824,7 +824,7 @@ GpStatus WINGDIPAPI GdipDeleteFontFamily(GpFontFamily *FontFamily)
if (!FontFamily->installed && !InterlockedDecrement(&FontFamily->ref)) if (!FontFamily->installed && !InterlockedDecrement(&FontFamily->ref))
{ {
heap_free(FontFamily); free(FontFamily);
} }
return Ok; return Ok;
@ -1057,7 +1057,7 @@ GpStatus WINGDIPAPI GdipNewPrivateFontCollection(GpFontCollection** fontCollecti
if (!fontCollection) if (!fontCollection)
return InvalidParameter; return InvalidParameter;
*fontCollection = heap_alloc_zero(sizeof(GpFontCollection)); *fontCollection = calloc(1, sizeof(GpFontCollection));
if (!*fontCollection) return OutOfMemory; if (!*fontCollection) return OutOfMemory;
(*fontCollection)->FontFamilies = NULL; (*fontCollection)->FontFamilies = NULL;
@ -1082,8 +1082,8 @@ GpStatus WINGDIPAPI GdipDeletePrivateFontCollection(GpFontCollection **fontColle
return InvalidParameter; return InvalidParameter;
for (i = 0; i < (*fontCollection)->count; i++) GdipDeleteFontFamily((*fontCollection)->FontFamilies[i]); for (i = 0; i < (*fontCollection)->count; i++) GdipDeleteFontFamily((*fontCollection)->FontFamilies[i]);
heap_free((*fontCollection)->FontFamilies); free((*fontCollection)->FontFamilies);
heap_free(*fontCollection); free(*fontCollection);
return Ok; 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_APPLE_UNICODE:
case TT_PLATFORM_MICROSOFT: 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++) for (len = 0; len < name_len / 2; len++)
ret[len] = (data[len * 2] << 8) | data[len * 2 + 1]; ret[len] = (data[len * 2] << 8) | data[len * 2 + 1];
ret[len] = 0; 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; len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, NULL, 0 ) + 1;
if (!len) if (!len)
return NULL; return NULL;
ret = heap_alloc(len * sizeof(WCHAR)); ret = malloc(len * sizeof(WCHAR));
len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, ret, len - 1 ); len = MultiByteToWideChar( codepage, 0, (char *)data, name_len, ret, len - 1 );
ret[len] = 0; ret[len] = 0;
return ret; return ret;
@ -1509,7 +1509,7 @@ GpStatus WINGDIPAPI GdipPrivateAddMemoryFont(GpFontCollection* fontCollection,
DeleteDC(param.hdc); DeleteDC(param.hdc);
} }
heap_free(name); free(name);
return ret; return ret;
} }
@ -1560,8 +1560,8 @@ void free_installed_fonts(void)
INT i; INT i;
for (i = 0; i < installedFontCollection.count; i++) for (i = 0; i < installedFontCollection.count; i++)
heap_free(installedFontCollection.FontFamilies[i]); free(installedFontCollection.FontFamilies[i]);
heap_free(installedFontCollection.FontFamilies); free(installedFontCollection.FontFamilies);
installedFontCollection.FontFamilies = NULL; installedFontCollection.FontFamilies = NULL;
installedFontCollection.allocated = 0; installedFontCollection.allocated = 0;
@ -1592,7 +1592,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
if (fonts->allocated == fonts->count) if (fonts->allocated == fonts->count)
{ {
INT new_alloc_count = fonts->allocated+50; 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) 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*)); memcpy(new_family_list, fonts->FontFamilies, fonts->count*sizeof(void*));
heap_free(fonts->FontFamilies); free(fonts->FontFamilies);
fonts->FontFamilies = new_family_list; fonts->FontFamilies = new_family_list;
fonts->allocated = new_alloc_count; fonts->allocated = new_alloc_count;
} }
family = heap_alloc(sizeof(*family)); family = malloc(sizeof(*family));
if (!family) if (!family)
{ {
if (param->is_system) 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) if (wcsicmp(lfw->lfFaceName, fonts->FontFamilies[i]->FamilyName) == 0)
{ {
heap_free(family); free(family);
return 1; return 1;
} }
} }
@ -1634,7 +1634,7 @@ static INT CALLBACK add_font_proc(const LOGFONTW *lfw, const TEXTMETRICW *ntm,
SelectObject(param->hdc, old_hfont); SelectObject(param->hdc, old_hfont);
DeleteObject(hfont); DeleteObject(hfont);
heap_free(family); free(family);
param->stat = OutOfMemory; param->stat = OutOfMemory;
return 0; return 0;
} }

View file

@ -143,7 +143,7 @@ ULONG WINAPI GdiplusShutdown_wrapper(ULONG_PTR token)
*/ */
void* WINGDIPAPI GdipAlloc(SIZE_T size) 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) void WINGDIPAPI GdipFree(void* ptr)
{ {
HeapFree(GetProcessHeap(), 0, ptr); free(ptr);
} }
/* Calculates the bezier points needed to fill in the arc portion starting at /* 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){ if(path->datalen == 0){
path->datalen = len * 2; path->datalen = len * 2;
path->pathdata.Points = heap_alloc_zero(path->datalen * sizeof(PointF)); path->pathdata.Points = calloc(path->datalen, sizeof(PointF));
if(!path->pathdata.Points) return FALSE; 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){ if(!path->pathdata.Types){
heap_free(path->pathdata.Points); free(path->pathdata.Points);
return FALSE; return FALSE;
} }
} }
@ -432,11 +432,11 @@ BOOL lengthen_path(GpPath *path, INT len)
while(path->datalen - path->pathdata.Count < len) while(path->datalen - path->pathdata.Count < len)
path->datalen *= 2; path->datalen *= 2;
path->pathdata.Points = heap_realloc(path->pathdata.Points, path->datalen * sizeof(PointF)); path->pathdata.Points = realloc(path->pathdata.Points, path->datalen * sizeof(PointF));
if(!path->pathdata.Points) return FALSE; if(!path->pathdata.Points) return FALSE;
path->pathdata.Types = heap_realloc(path->pathdata.Types, path->datalen); path->pathdata.Types = realloc(path->pathdata.Types, path->datalen);
if(!path->pathdata.Types) return FALSE; if(!path->pathdata.Types) return FALSE;
} }
return TRUE; return TRUE;
@ -477,8 +477,8 @@ void delete_element(region_element* element)
default: default:
delete_element(element->elementdata.combine.left); delete_element(element->elementdata.combine.left);
delete_element(element->elementdata.combine.right); delete_element(element->elementdata.combine.right);
heap_free(element->elementdata.combine.left); free(element->elementdata.combine.left);
heap_free(element->elementdata.combine.right); free(element->elementdata.combine.right);
break; break;
} }
} }

View file

@ -30,7 +30,6 @@
#include "objbase.h" #include "objbase.h"
#include "ocidl.h" #include "ocidl.h"
#include "wincodecsdk.h" #include "wincodecsdk.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
#include "gdiplus.h" #include "gdiplus.h"

View file

@ -531,7 +531,7 @@ static GpStatus alpha_blend_pixels_hrgn(GpGraphics *graphics, INT dst_x, INT dst
size = GetRegionData(hrgn, 0, NULL); size = GetRegionData(hrgn, 0, NULL);
rgndata = heap_alloc_zero(size); rgndata = malloc(size);
if (!rgndata) if (!rgndata)
{ {
DeleteObject(hrgn); DeleteObject(hrgn);
@ -550,7 +550,7 @@ static GpStatus alpha_blend_pixels_hrgn(GpGraphics *graphics, INT dst_x, INT dst
src_stride, fmt); src_stride, fmt);
} }
heap_free(rgndata); free(rgndata);
DeleteObject(hrgn); DeleteObject(hrgn);
@ -1331,7 +1331,7 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush,
{ {
BitmapData lockeddata; BitmapData lockeddata;
fill->bitmap_bits = heap_alloc_zero(sizeof(ARGB) * bitmap->width * bitmap->height); fill->bitmap_bits = calloc(bitmap->width * bitmap->height, sizeof(ARGB));
if (!fill->bitmap_bits) if (!fill->bitmap_bits)
stat = OutOfMemory; stat = OutOfMemory;
@ -1357,7 +1357,7 @@ static GpStatus brush_fill_pixels(GpGraphics *graphics, GpBrush *brush,
if (stat != Ok) if (stat != Ok)
{ {
heap_free(fill->bitmap_bits); free(fill->bitmap_bits);
fill->bitmap_bits = NULL; fill->bitmap_bits = NULL;
} }
} }
@ -1784,9 +1784,9 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
} }
count = custom->pathdata.Count; count = custom->pathdata.Count;
custptf = heap_alloc_zero(count * sizeof(PointF)); custptf = malloc(count * sizeof(PointF));
custpt = heap_alloc_zero(count * sizeof(POINT)); custpt = malloc(count * sizeof(POINT));
tp = heap_alloc_zero(count); tp = malloc(count);
if(!custptf || !custpt || !tp) if(!custptf || !custpt || !tp)
goto custend; goto custend;
@ -1817,9 +1817,9 @@ static void draw_cap(GpGraphics *graphics, COLORREF color, GpLineCap cap, REAL s
PolyDraw(graphics->hdc, custpt, tp, count); PolyDraw(graphics->hdc, custpt, tp, count);
custend: custend:
heap_free(custptf); free(custptf);
heap_free(custpt); free(custpt);
heap_free(tp); free(tp);
break; break;
default: default:
break; break;
@ -1921,9 +1921,9 @@ static void shorten_bezier_amt(GpPointF * pt, REAL amt, BOOL rev)
static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt, static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF * pt,
GDIPCONST BYTE * types, INT count, BOOL caps) GDIPCONST BYTE * types, INT count, BOOL caps)
{ {
POINT *pti = heap_alloc_zero(count * sizeof(POINT)); POINT *pti = malloc(count * sizeof(POINT));
BYTE *tp = heap_alloc_zero(count); BYTE *tp = malloc(count);
GpPointF *ptcopy = heap_alloc_zero(count * sizeof(GpPointF)); GpPointF *ptcopy = malloc(count * sizeof(GpPointF));
INT i, j; INT i, j;
GpStatus status = GenericError; GpStatus status = GenericError;
@ -2038,9 +2038,9 @@ static GpStatus draw_poly(GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *
status = Ok; status = Ok;
end: end:
heap_free(pti); free(pti);
heap_free(ptcopy); free(ptcopy);
heap_free(tp); free(tp);
return status; return status;
} }
@ -2084,7 +2084,7 @@ static GpStatus init_container(GraphicsContainerItem** container,
GDIPCONST GpGraphics* graphics, GraphicsContainerType type){ GDIPCONST GpGraphics* graphics, GraphicsContainerType type){
GpStatus sts; GpStatus sts;
*container = heap_alloc_zero(sizeof(GraphicsContainerItem)); *container = calloc(1, sizeof(GraphicsContainerItem));
if(!(*container)) if(!(*container))
return OutOfMemory; return OutOfMemory;
@ -2106,7 +2106,7 @@ static GpStatus init_container(GraphicsContainerItem** container,
sts = GdipCloneRegion(graphics->clip, &(*container)->clip); sts = GdipCloneRegion(graphics->clip, &(*container)->clip);
if(sts != Ok){ if(sts != Ok){
heap_free(*container); free(*container);
*container = NULL; *container = NULL;
return sts; return sts;
} }
@ -2117,7 +2117,7 @@ static GpStatus init_container(GraphicsContainerItem** container,
static void delete_container(GraphicsContainerItem* container) static void delete_container(GraphicsContainerItem* container)
{ {
GdipDeleteRegion(container->clip); GdipDeleteRegion(container->clip);
heap_free(container); free(container);
} }
static GpStatus restore_container(GpGraphics* graphics, static GpStatus restore_container(GpGraphics* graphics,
@ -2382,13 +2382,13 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
if(graphics == NULL) if(graphics == NULL)
return InvalidParameter; return InvalidParameter;
*graphics = heap_alloc_zero(sizeof(GpGraphics)); *graphics = calloc(1, sizeof(GpGraphics));
if(!*graphics) return OutOfMemory; if(!*graphics) return OutOfMemory;
GdipSetMatrixElements(&(*graphics)->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); GdipSetMatrixElements(&(*graphics)->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
if((retval = GdipCreateRegion(&(*graphics)->clip)) != Ok){ if((retval = GdipCreateRegion(&(*graphics)->clip)) != Ok){
heap_free(*graphics); free(*graphics);
return retval; return retval;
} }
@ -2434,14 +2434,14 @@ GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics)
{ {
GpStatus retval; GpStatus retval;
*graphics = heap_alloc_zero(sizeof(GpGraphics)); *graphics = calloc(1, sizeof(GpGraphics));
if(!*graphics) return OutOfMemory; if(!*graphics) return OutOfMemory;
GdipSetMatrixElements(&(*graphics)->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); GdipSetMatrixElements(&(*graphics)->worldtrans, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
GdipSetMatrixElements(&(*graphics)->gdi_transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0); GdipSetMatrixElements(&(*graphics)->gdi_transform, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
if((retval = GdipCreateRegion(&(*graphics)->clip)) != Ok){ if((retval = GdipCreateRegion(&(*graphics)->clip)) != Ok){
heap_free(*graphics); free(*graphics);
return retval; return retval;
} }
@ -2562,7 +2562,7 @@ GpStatus WINGDIPAPI GdipDeleteGraphics(GpGraphics *graphics)
* accessing freed memory. */ * accessing freed memory. */
graphics->busy = TRUE; graphics->busy = TRUE;
heap_free(graphics); free(graphics);
return Ok; return Ok;
} }
@ -2683,7 +2683,7 @@ GpStatus WINGDIPAPI GdipDrawBeziersI(GpGraphics *graphics, GpPen *pen,
if(graphics->busy) if(graphics->busy)
return ObjectBusy; return ObjectBusy;
pts = heap_alloc_zero(sizeof(GpPointF) * count); pts = malloc(sizeof(GpPointF) * count);
if(!pts) if(!pts)
return OutOfMemory; return OutOfMemory;
@ -2694,7 +2694,7 @@ GpStatus WINGDIPAPI GdipDrawBeziersI(GpGraphics *graphics, GpPen *pen,
ret = GdipDrawBeziers(graphics,pen,pts,count); ret = GdipDrawBeziers(graphics,pen,pts,count);
heap_free(pts); free(pts);
return ret; return ret;
} }
@ -2753,7 +2753,7 @@ GpStatus WINGDIPAPI GdipDrawClosedCurve2I(GpGraphics *graphics, GpPen *pen,
if(!points || count <= 0) if(!points || count <= 0)
return InvalidParameter; return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -2764,7 +2764,7 @@ GpStatus WINGDIPAPI GdipDrawClosedCurve2I(GpGraphics *graphics, GpPen *pen,
stat = GdipDrawClosedCurve2(graphics, pen, ptf, count, tension); stat = GdipDrawClosedCurve2(graphics, pen, ptf, count, tension);
heap_free(ptf); free(ptf);
return stat; return stat;
} }
@ -2789,7 +2789,7 @@ GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics *graphics, GpPen *pen,
if(!points) if(!points)
return InvalidParameter; return InvalidParameter;
pointsF = heap_alloc_zero(sizeof(GpPointF)*count); pointsF = malloc(sizeof(GpPointF) * count);
if(!pointsF) if(!pointsF)
return OutOfMemory; return OutOfMemory;
@ -2799,7 +2799,7 @@ GpStatus WINGDIPAPI GdipDrawCurveI(GpGraphics *graphics, GpPen *pen,
} }
ret = GdipDrawCurve(graphics,pen,pointsF,count); ret = GdipDrawCurve(graphics,pen,pointsF,count);
heap_free(pointsF); free(pointsF);
return ret; return ret;
} }
@ -2845,7 +2845,7 @@ GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen,
if(!points) if(!points)
return InvalidParameter; return InvalidParameter;
pointsF = heap_alloc_zero(sizeof(GpPointF)*count); pointsF = malloc(sizeof(GpPointF) * count);
if(!pointsF) if(!pointsF)
return OutOfMemory; return OutOfMemory;
@ -2855,7 +2855,7 @@ GpStatus WINGDIPAPI GdipDrawCurve2I(GpGraphics *graphics, GpPen *pen,
} }
ret = GdipDrawCurve2(graphics,pen,pointsF,count,tension); ret = GdipDrawCurve2(graphics,pen,pointsF,count,tension);
heap_free(pointsF); free(pointsF);
return ret; return ret;
} }
@ -3187,7 +3187,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
TRACE("src_area: %d x %d\n", src_area.Width, src_area.Height); TRACE("src_area: %d x %d\n", src_area.Width, src_area.Height);
src_data = heap_alloc_zero(sizeof(ARGB) * src_area.Width * src_area.Height); src_data = calloc(src_area.Width * src_area.Height, sizeof(ARGB));
if (!src_data) if (!src_data)
return OutOfMemory; return OutOfMemory;
src_stride = sizeof(ARGB) * src_area.Width; src_stride = sizeof(ARGB) * src_area.Width;
@ -3210,7 +3210,7 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
if (stat != Ok) if (stat != Ok)
{ {
heap_free(src_data); free(src_data);
return stat; return stat;
} }
@ -3245,10 +3245,10 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
y_dy = dst_to_src.matrix[3]; y_dy = dst_to_src.matrix[3];
/* Transform the bits as needed to the destination. */ /* Transform the bits as needed to the destination. */
dst_data = dst_dyn_data = heap_alloc_zero(sizeof(ARGB) * (dst_area.right - dst_area.left) * (dst_area.bottom - dst_area.top)); dst_data = dst_dyn_data = calloc((dst_area.right - dst_area.left) * (dst_area.bottom - dst_area.top), sizeof(ARGB));
if (!dst_data) if (!dst_data)
{ {
heap_free(src_data); free(src_data);
return OutOfMemory; return OutOfMemory;
} }
dst_color = (ARGB*)(dst_data); dst_color = (ARGB*)(dst_data);
@ -3288,9 +3288,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
gdi_transform_release(graphics); gdi_transform_release(graphics);
heap_free(src_data); free(src_data);
heap_free(dst_dyn_data); free(dst_dyn_data);
return stat; return stat;
} }
@ -3580,7 +3580,7 @@ GpStatus WINGDIPAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count); TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
ptf = heap_alloc_zero(count * sizeof(GpPointF)); ptf = malloc(count * sizeof(GpPointF));
if(!ptf) return OutOfMemory; if(!ptf) return OutOfMemory;
for(i = 0; i < count; i ++){ for(i = 0; i < count; i ++){
@ -3590,7 +3590,7 @@ GpStatus WINGDIPAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, GDIPCONST
retval = GdipDrawLines(graphics, pen, ptf, count); retval = GdipDrawLines(graphics, pen, ptf, count);
heap_free(ptf); free(ptf);
return retval; return retval;
} }
@ -3701,7 +3701,7 @@ static GpStatus SOFTWARE_GdipDrawThinPath(GpGraphics *graphics, GpPen *pen, GpPa
gp_output_area.Width = output_width; gp_output_area.Width = output_width;
gp_output_area.Height = output_height; gp_output_area.Height = output_height;
output_bits = heap_alloc_zero(output_width * output_height * sizeof(DWORD)); output_bits = calloc(output_width * output_height, sizeof(DWORD));
if (!output_bits) if (!output_bits)
stat = OutOfMemory; stat = OutOfMemory;
} }
@ -3711,7 +3711,7 @@ static GpStatus SOFTWARE_GdipDrawThinPath(GpGraphics *graphics, GpPen *pen, GpPa
if (pen->brush->bt != BrushTypeSolidColor) if (pen->brush->bt != BrushTypeSolidColor)
{ {
/* allocate and draw brush output */ /* allocate and draw brush output */
brush_bits = heap_alloc_zero(output_width * output_height * sizeof(DWORD)); brush_bits = calloc(output_width * output_height, sizeof(DWORD));
if (brush_bits) if (brush_bits)
{ {
@ -3736,7 +3736,7 @@ static GpStatus SOFTWARE_GdipDrawThinPath(GpGraphics *graphics, GpPen *pen, GpPa
if (dash_pattern_size != 0) if (dash_pattern_size != 0)
{ {
dash_pattern = dyn_dash_pattern = heap_alloc(dash_pattern_size); dash_pattern = dyn_dash_pattern = malloc(dash_pattern_size);
if (dyn_dash_pattern) if (dyn_dash_pattern)
{ {
@ -3918,9 +3918,9 @@ static GpStatus SOFTWARE_GdipDrawThinPath(GpGraphics *graphics, GpPen *pen, GpPa
gdi_transform_release(graphics); gdi_transform_release(graphics);
} }
heap_free(brush_bits); free(brush_bits);
heap_free(dyn_dash_pattern); free(dyn_dash_pattern);
heap_free(output_bits); free(output_bits);
} }
GdipDeletePath(flat_path); GdipDeletePath(flat_path);
@ -4134,7 +4134,7 @@ GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen,
if(!rects || count<=0) if(!rects || count<=0)
return InvalidParameter; return InvalidParameter;
rectsF = heap_alloc_zero(sizeof(GpRectF) * count); rectsF = malloc(sizeof(GpRectF) * count);
if(!rectsF) if(!rectsF)
return OutOfMemory; return OutOfMemory;
@ -4142,7 +4142,7 @@ GpStatus WINGDIPAPI GdipDrawRectanglesI(GpGraphics *graphics, GpPen *pen,
set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height); set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
ret = GdipDrawRectangles(graphics, pen, rectsF, count); ret = GdipDrawRectangles(graphics, pen, rectsF, count);
heap_free(rectsF); free(rectsF);
return ret; return ret;
} }
@ -4192,7 +4192,7 @@ GpStatus WINGDIPAPI GdipFillClosedCurve2I(GpGraphics *graphics, GpBrush *brush,
if(count == 1) /* Do nothing */ if(count == 1) /* Do nothing */
return Ok; return Ok;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -4203,7 +4203,7 @@ GpStatus WINGDIPAPI GdipFillClosedCurve2I(GpGraphics *graphics, GpBrush *brush,
stat = GdipFillClosedCurve2(graphics, brush, ptf, count, tension, fill); stat = GdipFillClosedCurve2(graphics, brush, ptf, count, tension, fill);
heap_free(ptf); free(ptf);
return stat; return stat;
} }
@ -4548,7 +4548,7 @@ GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GD
if(!rects || count <= 0) if(!rects || count <= 0)
return InvalidParameter; return InvalidParameter;
rectsF = heap_alloc_zero(sizeof(GpRectF)*count); rectsF = malloc(sizeof(GpRectF) * count);
if(!rectsF) if(!rectsF)
return OutOfMemory; return OutOfMemory;
@ -4556,7 +4556,7 @@ GpStatus WINGDIPAPI GdipFillRectanglesI(GpGraphics *graphics, GpBrush *brush, GD
set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height); set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
ret = GdipFillRectangles(graphics,brush,rectsF,count); ret = GdipFillRectangles(graphics,brush,rectsF,count);
heap_free(rectsF); free(rectsF);
return ret; return ret;
} }
@ -4665,7 +4665,7 @@ static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
gp_bound_rect.Width = bound_rect.right - bound_rect.left; gp_bound_rect.Width = bound_rect.right - bound_rect.left;
gp_bound_rect.Height = bound_rect.bottom - bound_rect.top; gp_bound_rect.Height = bound_rect.bottom - bound_rect.top;
pixel_data = heap_alloc_zero(sizeof(*pixel_data) * gp_bound_rect.Width * gp_bound_rect.Height); pixel_data = calloc(gp_bound_rect.Width * gp_bound_rect.Height, sizeof(*pixel_data));
if (!pixel_data) if (!pixel_data)
stat = OutOfMemory; stat = OutOfMemory;
@ -4680,7 +4680,7 @@ static GpStatus SOFTWARE_GdipFillRegion(GpGraphics *graphics, GpBrush *brush,
gp_bound_rect.Height, gp_bound_rect.Width * 4, hregion, gp_bound_rect.Height, gp_bound_rect.Width * 4, hregion,
PixelFormat32bppARGB); PixelFormat32bppARGB);
heap_free(pixel_data); free(pixel_data);
} }
DeleteObject(hregion); DeleteObject(hregion);
@ -5181,7 +5181,7 @@ GpStatus gdip_format_string(HDC hdc,
if(length == -1) length = lstrlenW(string); if(length == -1) length = lstrlenW(string);
stringdup = heap_alloc_zero((length + 1) * sizeof(WCHAR)); stringdup = calloc(length + 1, sizeof(WCHAR));
if(!stringdup) return OutOfMemory; if(!stringdup) return OutOfMemory;
if (!format) if (!format)
@ -5208,10 +5208,10 @@ GpStatus gdip_format_string(HDC hdc,
if (hotkeyprefix_count) if (hotkeyprefix_count)
{ {
hotkeyprefix_offsets = heap_alloc_zero(sizeof(INT) * hotkeyprefix_count); hotkeyprefix_offsets = calloc(hotkeyprefix_count, sizeof(INT));
if (!hotkeyprefix_offsets) if (!hotkeyprefix_offsets)
{ {
heap_free(stringdup); free(stringdup);
return OutOfMemory; return OutOfMemory;
} }
} }
@ -5358,8 +5358,8 @@ GpStatus gdip_format_string(HDC hdc,
break; break;
} }
heap_free(stringdup); free(stringdup);
heap_free(hotkeyprefix_offsets); free(hotkeyprefix_offsets);
return stat; return stat;
} }
@ -6604,8 +6604,8 @@ GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics,GpPen *pen,GDIPCONST G
TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count); TRACE("(%p, %p, %p, %d)\n", graphics, pen, points, count);
if(count<=0) return InvalidParameter; if(count <= 0) return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF) * count); ptf = malloc(sizeof(GpPointF) * count);
if (!ptf) return OutOfMemory; if (!ptf) return OutOfMemory;
for(i = 0;i < count; i++){ for(i = 0;i < count; i++){
@ -6614,7 +6614,7 @@ GpStatus WINGDIPAPI GdipDrawPolygonI(GpGraphics *graphics,GpPen *pen,GDIPCONST G
} }
ret = GdipDrawPolygon(graphics,pen,ptf,count); ret = GdipDrawPolygon(graphics,pen,ptf,count);
heap_free(ptf); free(ptf);
return ret; return ret;
} }
@ -6842,7 +6842,7 @@ GpStatus WINGDIPAPI GdipGetClip(GpGraphics *graphics, GpRegion *region)
/* free everything except root node and header */ /* free everything except root node and header */
delete_element(&region->node); delete_element(&region->node);
memcpy(region, clip, sizeof(GpRegion)); memcpy(region, clip, sizeof(GpRegion));
heap_free(clip); free(clip);
return Ok; return Ok;
} }
@ -6997,7 +6997,7 @@ GpStatus WINGDIPAPI GdipTransformPointsI(GpGraphics *graphics, GpCoordinateSpace
if(count <= 0) if(count <= 0)
return InvalidParameter; return InvalidParameter;
pointsF = heap_alloc_zero(sizeof(GpPointF) * count); pointsF = malloc(sizeof(GpPointF) * count);
if(!pointsF) if(!pointsF)
return OutOfMemory; return OutOfMemory;
@ -7013,7 +7013,7 @@ GpStatus WINGDIPAPI GdipTransformPointsI(GpGraphics *graphics, GpCoordinateSpace
points[i].X = gdip_round(pointsF[i].X); points[i].X = gdip_round(pointsF[i].X);
points[i].Y = gdip_round(pointsF[i].Y); points[i].Y = gdip_round(pointsF[i].Y);
} }
heap_free(pointsF); free(pointsF);
return ret; return ret;
} }
@ -7121,7 +7121,7 @@ GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT
if (flags & DriverStringOptionsCmapLookup) if (flags & DriverStringOptionsCmapLookup)
{ {
glyph_indices = dynamic_glyph_indices = heap_alloc_zero(sizeof(WORD) * length); glyph_indices = dynamic_glyph_indices = malloc(sizeof(WORD) * length);
if (!glyph_indices) if (!glyph_indices)
{ {
DeleteDC(hdc); DeleteDC(hdc);
@ -7163,7 +7163,7 @@ GpStatus WINGDIPAPI GdipMeasureDriverString(GpGraphics *graphics, GDIPCONST UINT
if (max_x < x) max_x = x; if (max_x < x) max_x = x;
} }
heap_free(dynamic_glyph_indices); free(dynamic_glyph_indices);
DeleteDC(hdc); DeleteDC(hdc);
DeleteObject(hfont); DeleteObject(hfont);
@ -7194,12 +7194,12 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1
if (!(flags & DriverStringOptionsRealizedAdvance) && length > 1) if (!(flags & DriverStringOptionsRealizedAdvance) && length > 1)
{ {
real_positions = heap_alloc(sizeof(*real_positions) * length); real_positions = malloc(sizeof(*real_positions) * length);
eto_positions = heap_alloc(sizeof(*eto_positions) * 2 * (length - 1)); eto_positions = malloc(sizeof(*eto_positions) * 2 * (length - 1));
if (!real_positions || !eto_positions) if (!real_positions || !eto_positions)
{ {
heap_free(real_positions); free(real_positions);
heap_free(eto_positions); free(eto_positions);
return OutOfMemory; return OutOfMemory;
} }
} }
@ -7257,8 +7257,8 @@ static GpStatus GDI32_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UINT1
DeleteObject(hfont); DeleteObject(hfont);
heap_free(real_positions); free(real_positions);
heap_free(eto_positions); free(eto_positions);
return Ok; return Ok;
} }
@ -7295,7 +7295,7 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
if (flags & unsupported_flags) if (flags & unsupported_flags)
FIXME("Ignoring flags %x\n", flags & unsupported_flags); FIXME("Ignoring flags %x\n", flags & unsupported_flags);
pti = heap_alloc_zero(sizeof(POINT) * length); pti = malloc(sizeof(POINT) * length);
if (!pti) if (!pti)
return OutOfMemory; return OutOfMemory;
@ -7308,10 +7308,10 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
} }
else else
{ {
real_positions = heap_alloc_zero(sizeof(PointF) * length); real_positions = malloc(sizeof(PointF) * length);
if (!real_positions) if (!real_positions)
{ {
heap_free(pti); free(pti);
return OutOfMemory; return OutOfMemory;
} }
@ -7320,7 +7320,7 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, real_positions, length); gdip_transform_points(graphics, WineCoordinateSpaceGdiDevice, CoordinateSpaceWorld, real_positions, length);
round_points(pti, real_positions, length); round_points(pti, real_positions, length);
heap_free(real_positions); free(real_positions);
} }
get_font_hfont(graphics, font, format, &hfont, NULL, matrix); get_font_hfont(graphics, font, format, &hfont, NULL, matrix);
@ -7340,7 +7340,7 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
if (glyphsize == GDI_ERROR) if (glyphsize == GDI_ERROR)
{ {
ERR("GetGlyphOutlineW failed\n"); ERR("GetGlyphOutlineW failed\n");
heap_free(pti); free(pti);
DeleteDC(hdc); DeleteDC(hdc);
DeleteObject(hfont); DeleteObject(hfont);
return GenericError; return GenericError;
@ -7372,21 +7372,21 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
if (max_glyphsize == 0) if (max_glyphsize == 0)
{ {
/* Nothing to draw. */ /* Nothing to draw. */
heap_free(pti); free(pti);
DeleteDC(hdc); DeleteDC(hdc);
DeleteObject(hfont); DeleteObject(hfont);
return Ok; return Ok;
} }
glyph_mask = heap_alloc_zero(max_glyphsize); glyph_mask = calloc(1, max_glyphsize);
text_mask = heap_alloc_zero((max_x - min_x) * (max_y - min_y)); text_mask = calloc(1, (max_x - min_x) * (max_y - min_y));
text_mask_stride = max_x - min_x; text_mask_stride = max_x - min_x;
if (!(glyph_mask && text_mask)) if (!(glyph_mask && text_mask))
{ {
heap_free(glyph_mask); free(glyph_mask);
heap_free(text_mask); free(text_mask);
heap_free(pti); free(pti);
DeleteDC(hdc); DeleteDC(hdc);
DeleteObject(hfont); DeleteObject(hfont);
return OutOfMemory; return OutOfMemory;
@ -7421,16 +7421,16 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
} }
} }
heap_free(pti); free(pti);
DeleteDC(hdc); DeleteDC(hdc);
DeleteObject(hfont); DeleteObject(hfont);
heap_free(glyph_mask); free(glyph_mask);
/* get the brush data */ /* get the brush data */
pixel_data = heap_alloc_zero(4 * (max_x - min_x) * (max_y - min_y)); pixel_data = calloc((max_x - min_x) * (max_y - min_y), 4);
if (!pixel_data) if (!pixel_data)
{ {
heap_free(text_mask); free(text_mask);
return OutOfMemory; return OutOfMemory;
} }
@ -7443,8 +7443,8 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
stat = brush_fill_pixels(graphics, (GpBrush*)brush, (DWORD*)pixel_data, &pixel_area, pixel_area.Width); stat = brush_fill_pixels(graphics, (GpBrush*)brush, (DWORD*)pixel_data, &pixel_area, pixel_area.Width);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(text_mask); free(text_mask);
heap_free(pixel_data); free(pixel_data);
return stat; return stat;
} }
@ -7461,7 +7461,7 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
} }
} }
heap_free(text_mask); free(text_mask);
gdi_transform_acquire(graphics); gdi_transform_acquire(graphics);
@ -7471,7 +7471,7 @@ static GpStatus SOFTWARE_GdipDrawDriverString(GpGraphics *graphics, GDIPCONST UI
gdi_transform_release(graphics); gdi_transform_release(graphics);
heap_free(pixel_data); free(pixel_data);
return stat; return stat;
} }

View file

@ -45,7 +45,7 @@ struct path_list_node_t {
/* init list */ /* init list */
static BOOL init_path_list(path_list_node_t **node, REAL x, REAL y) static BOOL init_path_list(path_list_node_t **node, REAL x, REAL y)
{ {
*node = heap_alloc_zero(sizeof(path_list_node_t)); *node = calloc(1, sizeof(path_list_node_t));
if(!*node) if(!*node)
return FALSE; return FALSE;
@ -64,7 +64,7 @@ static void free_path_list(path_list_node_t *node)
while(n){ while(n){
n = n->next; n = n->next;
heap_free(node); free(node);
node = n; node = n;
} }
} }
@ -79,7 +79,7 @@ static path_list_node_t* add_path_list_node(path_list_node_t *node, REAL x, REAL
{ {
path_list_node_t *new; path_list_node_t *new;
new = heap_alloc_zero(sizeof(path_list_node_t)); new = calloc(1, sizeof(path_list_node_t));
if(!new) if(!new)
return NULL; return NULL;
@ -319,7 +319,7 @@ GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x, REAL y, REAL width,
if(count == 0) if(count == 0)
return Ok; return Ok;
points = heap_alloc_zero(sizeof(GpPointF)*count); points = malloc(sizeof(GpPointF) * count);
if(!points) if(!points)
return OutOfMemory; return OutOfMemory;
@ -327,7 +327,7 @@ GpStatus WINGDIPAPI GdipAddPathArc(GpPath *path, REAL x, REAL y, REAL width,
status = extend_current_figure(path, points, count, PathPointTypeBezier); status = extend_current_figure(path, points, count, PathPointTypeBezier);
heap_free(points); free(points);
return status; return status;
} }
@ -401,7 +401,7 @@ GpStatus WINGDIPAPI GdipAddPathBeziersI(GpPath *path, GDIPCONST GpPoint *points,
if(!points || ((count - 1) % 3)) if(!points || ((count - 1) % 3))
return InvalidParameter; return InvalidParameter;
ptsF = heap_alloc_zero(sizeof(GpPointF) * count); ptsF = malloc(sizeof(GpPointF) * count);
if(!ptsF) if(!ptsF)
return OutOfMemory; return OutOfMemory;
@ -411,7 +411,7 @@ GpStatus WINGDIPAPI GdipAddPathBeziersI(GpPath *path, GDIPCONST GpPoint *points,
} }
ret = GdipAddPathBeziers(path, ptsF, count); ret = GdipAddPathBeziers(path, ptsF, count);
heap_free(ptsF); free(ptsF);
return ret; return ret;
} }
@ -446,11 +446,11 @@ GpStatus WINGDIPAPI GdipAddPathClosedCurve2(GpPath *path, GDIPCONST GpPointF *po
if(!path || !points || count <= 1) if(!path || !points || count <= 1)
return InvalidParameter; return InvalidParameter;
pt = heap_alloc_zero(len_pt * sizeof(GpPointF)); pt = malloc(len_pt * sizeof(GpPointF));
pts = heap_alloc_zero((count + 1)*sizeof(GpPointF)); pts = malloc((count + 1) * sizeof(GpPointF));
if(!pt || !pts){ if(!pt || !pts){
heap_free(pt); free(pt);
heap_free(pts); free(pts);
return OutOfMemory; return OutOfMemory;
} }
@ -496,8 +496,8 @@ GpStatus WINGDIPAPI GdipAddPathClosedCurve2(GpPath *path, GDIPCONST GpPointF *po
path->newfigure = TRUE; path->newfigure = TRUE;
} }
heap_free(pts); free(pts);
heap_free(pt); free(pt);
return stat; return stat;
} }
@ -514,7 +514,7 @@ GpStatus WINGDIPAPI GdipAddPathClosedCurve2I(GpPath *path, GDIPCONST GpPoint *po
if(!path || !points || count <= 1) if(!path || !points || count <= 1)
return InvalidParameter; return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -525,7 +525,7 @@ GpStatus WINGDIPAPI GdipAddPathClosedCurve2I(GpPath *path, GDIPCONST GpPoint *po
stat = GdipAddPathClosedCurve2(path, ptf, count, tension); stat = GdipAddPathClosedCurve2(path, ptf, count, tension);
heap_free(ptf); free(ptf);
return stat; return stat;
} }
@ -556,7 +556,7 @@ GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points,
if(!path || !points || offset + 1 >= count || count - offset < nseg + 1 || nseg < 1) if(!path || !points || offset + 1 >= count || count - offset < nseg + 1 || nseg < 1)
return InvalidParameter; return InvalidParameter;
pt = heap_alloc_zero(len_pt * sizeof(GpPointF)); pt = calloc(len_pt, sizeof(GpPointF));
if(!pt) if(!pt)
return OutOfMemory; return OutOfMemory;
@ -603,7 +603,7 @@ GpStatus WINGDIPAPI GdipAddPathCurve3(GpPath *path, GDIPCONST GpPointF *points,
stat = extend_current_figure(path, pt, len_pt, PathPointTypeBezier); stat = extend_current_figure(path, pt, len_pt, PathPointTypeBezier);
heap_free(pt); free(pt);
return stat; return stat;
} }
@ -636,7 +636,7 @@ GpStatus WINGDIPAPI GdipAddPathCurve3I(GpPath *path, GDIPCONST GpPoint *points,
if(!path || !points || offset + 1 >= count || count - offset < nseg + 1 || nseg < 1) if(!path || !points || offset + 1 >= count || count - offset < nseg + 1 || nseg < 1)
return InvalidParameter; return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -647,7 +647,7 @@ GpStatus WINGDIPAPI GdipAddPathCurve3I(GpPath *path, GDIPCONST GpPoint *points,
stat = GdipAddPathCurve3(path, ptf, count, offset, nseg, tension); stat = GdipAddPathCurve3(path, ptf, count, offset, nseg, tension);
heap_free(ptf); free(ptf);
return stat; return stat;
} }
@ -714,8 +714,8 @@ GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath *path, GDIPCONST GpPoint *points, I
if(count <= 0) if(count <= 0)
return InvalidParameter; return InvalidParameter;
pointsF = heap_alloc_zero(sizeof(GpPointF) * count); pointsF = malloc(sizeof(GpPointF) * count);
if(!pointsF) return OutOfMemory; if(!pointsF) return OutOfMemory;
for(i = 0;i < count; i++){ for(i = 0;i < count; i++){
pointsF[i].X = (REAL)points[i].X; pointsF[i].X = (REAL)points[i].X;
@ -724,7 +724,7 @@ GpStatus WINGDIPAPI GdipAddPathLine2I(GpPath *path, GDIPCONST GpPoint *points, I
stat = GdipAddPathLine2(path, pointsF, count); stat = GdipAddPathLine2(path, pointsF, count);
heap_free(pointsF); free(pointsF);
return stat; return stat;
} }
@ -842,7 +842,7 @@ GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REA
if(count == 0) if(count == 0)
return Ok; return Ok;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -850,12 +850,12 @@ GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REA
status = GdipAddPathLine(path, x + width/2, y + height/2, ptf[0].X, ptf[0].Y); status = GdipAddPathLine(path, x + width/2, y + height/2, ptf[0].X, ptf[0].Y);
if(status != Ok){ if(status != Ok){
heap_free(ptf); free(ptf);
return status; return status;
} }
/* one spline is already added as a line endpoint */ /* one spline is already added as a line endpoint */
if(!lengthen_path(path, count - 1)){ if(!lengthen_path(path, count - 1)){
heap_free(ptf); free(ptf);
return OutOfMemory; return OutOfMemory;
} }
@ -867,7 +867,7 @@ GpStatus WINGDIPAPI GdipAddPathPie(GpPath *path, REAL x, REAL y, REAL width, REA
GdipClosePathFigure(path); GdipClosePathFigure(path);
heap_free(ptf); free(ptf);
return status; return status;
} }
@ -918,7 +918,7 @@ GpStatus WINGDIPAPI GdipAddPathPolygonI(GpPath *path, GDIPCONST GpPoint *points,
if(!points || count < 3) if(!points || count < 3)
return InvalidParameter; return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF) * count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) if(!ptf)
return OutOfMemory; return OutOfMemory;
@ -929,7 +929,7 @@ GpStatus WINGDIPAPI GdipAddPathPolygonI(GpPath *path, GDIPCONST GpPoint *points,
status = GdipAddPathPolygon(path, ptf, count); status = GdipAddPathPolygon(path, ptf, count);
heap_free(ptf); free(ptf);
return status; return status;
} }
@ -981,11 +981,11 @@ static GpStatus format_string_callback(HDC dc,
status = GenericError; status = GenericError;
break; break;
} }
origph = ph = heap_alloc_zero(len); origph = ph = calloc(1, len);
start = (char *)ph; start = (char *)ph;
if (!ph || !lengthen_path(path, len / sizeof(POINTFX))) if (!ph || !lengthen_path(path, len / sizeof(POINTFX)))
{ {
heap_free(ph); free(ph);
status = OutOfMemory; status = OutOfMemory;
break; break;
} }
@ -1036,7 +1036,7 @@ static GpStatus format_string_callback(HDC dc,
x += gm.gmCellIncX * args->scale; x += gm.gmCellIncX * args->scale;
y += gm.gmCellIncY * args->scale; y += gm.gmCellIncY * args->scale;
heap_free(origph); free(origph);
if (status != Ok) if (status != Ok)
break; break;
} }
@ -1125,10 +1125,10 @@ GpStatus WINGDIPAPI GdipAddPathString(GpPath* path, GDIPCONST WCHAR* string, INT
if (status != Ok) /* free backup */ if (status != Ok) /* free backup */
{ {
heap_free(path->pathdata.Points); free(path->pathdata.Points);
heap_free(path->pathdata.Types); free(path->pathdata.Types);
*path = *backup; *path = *backup;
heap_free(backup); free(backup);
return status; return status;
} }
if (format->line_align == StringAlignmentCenter && layoutRect->Y + args.maxY < layoutRect->Height) if (format->line_align == StringAlignmentCenter && layoutRect->Y + args.maxY < layoutRect->Height)
@ -1179,17 +1179,17 @@ GpStatus WINGDIPAPI GdipClonePath(GpPath* path, GpPath **clone)
if(!path || !clone) if(!path || !clone)
return InvalidParameter; return InvalidParameter;
*clone = heap_alloc_zero(sizeof(GpPath)); *clone = malloc(sizeof(GpPath));
if(!*clone) return OutOfMemory; if(!*clone) return OutOfMemory;
**clone = *path; **clone = *path;
(*clone)->pathdata.Points = heap_alloc_zero(path->datalen * sizeof(PointF)); (*clone)->pathdata.Points = malloc(path->datalen * sizeof(PointF));
(*clone)->pathdata.Types = heap_alloc_zero(path->datalen); (*clone)->pathdata.Types = malloc(path->datalen);
if(!(*clone)->pathdata.Points || !(*clone)->pathdata.Types){ if(!(*clone)->pathdata.Points || !(*clone)->pathdata.Types){
heap_free((*clone)->pathdata.Points); free((*clone)->pathdata.Points);
heap_free((*clone)->pathdata.Types); free((*clone)->pathdata.Types);
heap_free(*clone); free(*clone);
return OutOfMemory; return OutOfMemory;
} }
@ -1241,7 +1241,7 @@ GpStatus WINGDIPAPI GdipCreatePath(GpFillMode fill, GpPath **path)
if(!path) if(!path)
return InvalidParameter; return InvalidParameter;
*path = heap_alloc_zero(sizeof(GpPath)); *path = calloc(1, sizeof(GpPath));
if(!*path) return OutOfMemory; if(!*path) return OutOfMemory;
(*path)->fill = fill; (*path)->fill = fill;
@ -1265,8 +1265,8 @@ GpStatus WINGDIPAPI GdipCreatePath2(GDIPCONST GpPointF* points,
return OutOfMemory; return OutOfMemory;
} }
*path = heap_alloc_zero(sizeof(GpPath)); *path = calloc(1, sizeof(GpPath));
if(!*path) return OutOfMemory; if(!*path) return OutOfMemory;
if(count > 1 && (types[count-1] & PathPointTypePathTypeMask) == PathPointTypeStart) if(count > 1 && (types[count-1] & PathPointTypePathTypeMask) == PathPointTypeStart)
count = 0; count = 0;
@ -1284,13 +1284,13 @@ GpStatus WINGDIPAPI GdipCreatePath2(GDIPCONST GpPointF* points,
} }
} }
(*path)->pathdata.Points = heap_alloc_zero(count * sizeof(PointF)); (*path)->pathdata.Points = malloc(count * sizeof(PointF));
(*path)->pathdata.Types = heap_alloc_zero(count); (*path)->pathdata.Types = malloc(count);
if(!(*path)->pathdata.Points || !(*path)->pathdata.Types){ if(!(*path)->pathdata.Points || !(*path)->pathdata.Types){
heap_free((*path)->pathdata.Points); free((*path)->pathdata.Points);
heap_free((*path)->pathdata.Types); free((*path)->pathdata.Types);
heap_free(*path); free(*path);
return OutOfMemory; return OutOfMemory;
} }
@ -1316,7 +1316,7 @@ GpStatus WINGDIPAPI GdipCreatePath2I(GDIPCONST GpPoint* points,
TRACE("(%p, %p, %d, %d, %p)\n", points, types, count, fill, path); TRACE("(%p, %p, %d, %d, %p)\n", points, types, count, fill, path);
ptF = heap_alloc_zero(sizeof(GpPointF)*count); ptF = malloc(sizeof(GpPointF) * count);
for(i = 0;i < count; i++){ for(i = 0;i < count; i++){
ptF[i].X = (REAL)points[i].X; ptF[i].X = (REAL)points[i].X;
@ -1325,7 +1325,7 @@ GpStatus WINGDIPAPI GdipCreatePath2I(GDIPCONST GpPoint* points,
ret = GdipCreatePath2(ptF, types, count, fill, path); ret = GdipCreatePath2(ptF, types, count, fill, path);
heap_free(ptF); free(ptF);
return ret; return ret;
} }
@ -1337,9 +1337,9 @@ GpStatus WINGDIPAPI GdipDeletePath(GpPath *path)
if(!path) if(!path)
return InvalidParameter; return InvalidParameter;
heap_free(path->pathdata.Points); free(path->pathdata.Points);
heap_free(path->pathdata.Types); free(path->pathdata.Types);
heap_free(path); free(path);
return Ok; return Ok;
} }
@ -1510,8 +1510,8 @@ GpStatus WINGDIPAPI GdipGetPathPointsI(GpPath *path, GpPoint* points, INT count)
if(count <= 0) if(count <= 0)
return InvalidParameter; return InvalidParameter;
ptf = heap_alloc_zero(sizeof(GpPointF)*count); ptf = malloc(sizeof(GpPointF) * count);
if(!ptf) return OutOfMemory; if(!ptf) return OutOfMemory;
ret = GdipGetPathPoints(path,ptf,count); ret = GdipGetPathPoints(path,ptf,count);
if(ret == Ok) if(ret == Ok)
@ -1519,7 +1519,7 @@ GpStatus WINGDIPAPI GdipGetPathPointsI(GpPath *path, GpPoint* points, INT count)
points[i].X = gdip_round(ptf[i].X); points[i].X = gdip_round(ptf[i].X);
points[i].Y = gdip_round(ptf[i].Y); points[i].Y = gdip_round(ptf[i].Y);
}; };
heap_free(ptf); free(ptf);
return ret; return ret;
} }
@ -1673,12 +1673,12 @@ GpStatus WINGDIPAPI GdipReversePath(GpPath* path)
if(count == 0) return Ok; if(count == 0) return Ok;
revpath.Points = heap_alloc_zero(sizeof(GpPointF)*count); revpath.Points = calloc(count, sizeof(GpPointF));
revpath.Types = heap_alloc_zero(sizeof(BYTE)*count); revpath.Types = calloc(count, sizeof(BYTE));
revpath.Count = count; revpath.Count = count;
if(!revpath.Points || !revpath.Types){ if(!revpath.Points || !revpath.Types){
heap_free(revpath.Points); free(revpath.Points);
heap_free(revpath.Types); free(revpath.Types);
return OutOfMemory; return OutOfMemory;
} }
@ -1708,8 +1708,8 @@ GpStatus WINGDIPAPI GdipReversePath(GpPath* path)
memcpy(path->pathdata.Points, revpath.Points, sizeof(GpPointF)*count); memcpy(path->pathdata.Points, revpath.Points, sizeof(GpPointF)*count);
memcpy(path->pathdata.Types, revpath.Types, sizeof(BYTE)*count); memcpy(path->pathdata.Types, revpath.Types, sizeof(BYTE)*count);
heap_free(revpath.Points); free(revpath.Points);
heap_free(revpath.Types); free(revpath.Types);
return Ok; return Ok;
} }
@ -2221,7 +2221,7 @@ static void add_anchor(const GpPointF *endpoint, const GpPointF *nextpoint,
if (!custom->fill) if (!custom->fill)
{ {
tmp_points = heap_alloc_zero(custom->pathdata.Count * sizeof(GpPoint)); tmp_points = malloc(custom->pathdata.Count * sizeof(GpPoint));
if (!tmp_points) { if (!tmp_points) {
ERR("Out of memory\n"); ERR("Out of memory\n");
return; return;
@ -2378,15 +2378,15 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed,
break; break;
} }
dash_pattern_scaled = heap_alloc(dash_count * sizeof(REAL)); dash_pattern_scaled = malloc(dash_count * sizeof(REAL));
if (!dash_pattern_scaled) return; if (!dash_pattern_scaled) return;
for (i = 0; i < dash_count; i++) for (i = 0; i < dash_count; i++)
dash_pattern_scaled[i] = dash_pattern_scaling * dash_pattern[i]; dash_pattern_scaled[i] = dash_pattern_scaling * dash_pattern[i];
tmp_points = heap_alloc_zero((end - start + 2) * sizeof(GpPoint)); tmp_points = calloc(end - start + 2, sizeof(GpPoint));
if (!tmp_points) { if (!tmp_points) {
heap_free(dash_pattern_scaled); free(dash_pattern_scaled);
return; /* FIXME */ return; /* FIXME */
} }
@ -2466,8 +2466,8 @@ static void widen_dashed_figure(GpPath *path, int start, int end, int closed,
closed ? LineCapFlat : pen->endcap, pen->customend, last_point); closed ? LineCapFlat : pen->endcap, pen->customend, last_point);
} }
heap_free(dash_pattern_scaled); free(dash_pattern_scaled);
heap_free(tmp_points); free(tmp_points);
} }
GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix, GpStatus WINGDIPAPI GdipWidenPath(GpPath *path, GpPen *pen, GpMatrix *matrix,
@ -2632,10 +2632,10 @@ GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y,
fail: fail:
/* reverting */ /* reverting */
heap_free(path->pathdata.Points); free(path->pathdata.Points);
heap_free(path->pathdata.Types); free(path->pathdata.Types);
memcpy(path, backup, sizeof(*path)); memcpy(path, backup, sizeof(*path));
heap_free(backup); free(backup);
return retstat; return retstat;
} }
@ -2678,10 +2678,10 @@ GpStatus WINGDIPAPI GdipAddPathRectangles(GpPath *path, GDIPCONST GpRectF *rects
fail: fail:
/* reverting */ /* reverting */
heap_free(path->pathdata.Points); free(path->pathdata.Points);
heap_free(path->pathdata.Types); free(path->pathdata.Types);
memcpy(path, backup, sizeof(*path)); memcpy(path, backup, sizeof(*path));
heap_free(backup); free(backup);
return retstat; return retstat;
} }
@ -2700,13 +2700,13 @@ GpStatus WINGDIPAPI GdipAddPathRectanglesI(GpPath *path, GDIPCONST GpRect *rects
if(count < 0) if(count < 0)
return OutOfMemory; return OutOfMemory;
rectsF = heap_alloc_zero(sizeof(GpRectF)*count); rectsF = malloc(sizeof(GpRectF) * count);
for(i = 0;i < count;i++) for(i = 0;i < count;i++)
set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height); set_rect(&rectsF[i], rects[i].X, rects[i].Y, rects[i].Width, rects[i].Height);
retstat = GdipAddPathRectangles(path, rectsF, count); retstat = GdipAddPathRectangles(path, rectsF, count);
heap_free(rectsF); free(rectsF);
return retstat; return retstat;
} }

View file

@ -92,7 +92,7 @@ static ColorPalette *get_palette(IWICBitmapFrameDecode *frame, WICBitmapPaletteT
UINT count; UINT count;
IWICPalette_GetColorCount(wic_palette, &count); IWICPalette_GetColorCount(wic_palette, &count);
palette = heap_alloc(2 * sizeof(UINT) + count * sizeof(ARGB)); palette = malloc(2 * sizeof(UINT) + count * sizeof(ARGB));
IWICPalette_GetColors(wic_palette, count, (UINT *)palette->Entries, &palette->Count); IWICPalette_GetColors(wic_palette, count, (UINT *)palette->Entries, &palette->Count);
IWICPalette_GetType(wic_palette, &type); IWICPalette_GetType(wic_palette, &type);
@ -1193,7 +1193,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
{ {
lockeddata->Stride = (((act_rect.Width * bitspp + 7) / 8) + 3) & ~3; lockeddata->Stride = (((act_rect.Width * bitspp + 7) / 8) + 3) & ~3;
bitmap->bitmapbits = heap_alloc_zero(lockeddata->Stride * act_rect.Height); bitmap->bitmapbits = calloc(lockeddata->Stride, act_rect.Height);
if (!bitmap->bitmapbits) if (!bitmap->bitmapbits)
{ {
@ -1222,7 +1222,7 @@ GpStatus WINGDIPAPI GdipBitmapLockBits(GpBitmap* bitmap, GDIPCONST GpRect* rect,
if (stat != Ok) if (stat != Ok)
{ {
heap_free(bitmap->bitmapbits); free(bitmap->bitmapbits);
bitmap->bitmapbits = NULL; bitmap->bitmapbits = NULL;
image_unlock(&bitmap->image); image_unlock(&bitmap->image);
return stat; return stat;
@ -1271,7 +1271,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
if(!(lockeddata->Reserved & ImageLockModeWrite)){ if(!(lockeddata->Reserved & ImageLockModeWrite)){
bitmap->lockmode = 0; bitmap->lockmode = 0;
heap_free(bitmap->bitmapbits); free(bitmap->bitmapbits);
bitmap->bitmapbits = NULL; bitmap->bitmapbits = NULL;
image_unlock(&bitmap->image); image_unlock(&bitmap->image);
return Ok; return Ok;
@ -1303,7 +1303,7 @@ GpStatus WINGDIPAPI GdipBitmapUnlockBits(GpBitmap* bitmap,
ERR("failed to convert pixels; this should never happen\n"); ERR("failed to convert pixels; this should never happen\n");
} }
heap_free(bitmap->bitmapbits); free(bitmap->bitmapbits);
bitmap->bitmapbits = NULL; bitmap->bitmapbits = NULL;
bitmap->lockmode = 0; bitmap->lockmode = 0;
@ -1349,7 +1349,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height,
src_palette = srcBitmap->image.palette; src_palette = srcBitmap->image.palette;
dst_palette = heap_alloc_zero(sizeof(UINT) * 2 + sizeof(ARGB) * src_palette->Count); dst_palette = calloc(1, sizeof(UINT) * 2 + sizeof(ARGB) * src_palette->Count);
if (dst_palette) if (dst_palette)
{ {
@ -1357,7 +1357,7 @@ GpStatus WINGDIPAPI GdipCloneBitmapArea(REAL x, REAL y, REAL width, REAL height,
dst_palette->Count = src_palette->Count; dst_palette->Count = src_palette->Count;
memcpy(dst_palette->Entries, src_palette->Entries, sizeof(ARGB) * src_palette->Count); memcpy(dst_palette->Entries, src_palette->Entries, sizeof(ARGB) * src_palette->Count);
heap_free((*dstBitmap)->image.palette); free((*dstBitmap)->image.palette);
(*dstBitmap)->image.palette = dst_palette; (*dstBitmap)->image.palette = dst_palette;
} }
else else
@ -1402,7 +1402,7 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
metafile = (GpMetafile*)image; metafile = (GpMetafile*)image;
result = heap_alloc_zero(sizeof(*result)); result = calloc(1, sizeof(*result));
if (!result) if (!result)
return OutOfMemory; return OutOfMemory;
@ -1420,7 +1420,7 @@ GpStatus WINGDIPAPI GdipCloneImage(GpImage *image, GpImage **cloneImage)
if (!result->hemf) if (!result->hemf)
{ {
heap_free(result); free(result);
return OutOfMemory; return OutOfMemory;
} }
@ -1683,7 +1683,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
bih.biClrUsed = 0; bih.biClrUsed = 0;
bih.biClrImportant = 0; bih.biClrImportant = 0;
bits = heap_alloc(height * stride); bits = malloc(height * stride);
if (!bits) if (!bits)
{ {
DeleteObject(iinfo.hbmColor); DeleteObject(iinfo.hbmColor);
@ -1709,7 +1709,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
if (!screendc || ((color_scanlines == 0 || mask_scanlines == 0) && if (!screendc || ((color_scanlines == 0 || mask_scanlines == 0) &&
GetLastError() == ERROR_INVALID_PARAMETER)) GetLastError() == ERROR_INVALID_PARAMETER))
{ {
heap_free(bits); free(bits);
GdipBitmapUnlockBits(*bitmap, &lockeddata); GdipBitmapUnlockBits(*bitmap, &lockeddata);
GdipDisposeImage(&(*bitmap)->image); GdipDisposeImage(&(*bitmap)->image);
return GenericError; return GenericError;
@ -1731,7 +1731,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHICON(HICON hicon, GpBitmap** bitmap)
dst_row += lockeddata.Stride; dst_row += lockeddata.Stride;
} }
heap_free(bits); free(bits);
GdipBitmapUnlockBits(*bitmap, &lockeddata); GdipBitmapUnlockBits(*bitmap, &lockeddata);
@ -1853,7 +1853,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
{ {
INT size = abs(stride) * height; INT size = abs(stride) * height;
own_bits = bits = heap_alloc_zero(size); own_bits = bits = calloc(1, size);
if (!own_bits) return OutOfMemory; if (!own_bits) return OutOfMemory;
if (stride < 0) if (stride < 0)
@ -1861,11 +1861,11 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
} }
} }
*bitmap = heap_alloc_zero(sizeof(GpBitmap)); *bitmap = calloc(1, sizeof(GpBitmap));
if(!*bitmap) if(!*bitmap)
{ {
DeleteObject(hbitmap); DeleteObject(hbitmap);
heap_free(own_bits); free(own_bits);
return OutOfMemory; return OutOfMemory;
} }
@ -1899,7 +1899,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromScan0(INT width, INT height, INT stride,
format == PixelFormat4bppIndexed || format == PixelFormat4bppIndexed ||
format == PixelFormat8bppIndexed) format == PixelFormat8bppIndexed)
{ {
(*bitmap)->image.palette = heap_alloc_zero(sizeof(UINT) * 2 + sizeof(ARGB) * (1 << PIXELFORMATBPP(format))); (*bitmap)->image.palette = calloc(1, sizeof(UINT) * 2 + sizeof(ARGB) * (1 << PIXELFORMATBPP(format)));
if (!(*bitmap)->image.palette) if (!(*bitmap)->image.palette)
{ {
@ -1971,13 +1971,13 @@ GpStatus WINGDIPAPI GdipCreateCachedBitmap(GpBitmap *bitmap, GpGraphics *graphic
if(!bitmap || !graphics || !cachedbmp) if(!bitmap || !graphics || !cachedbmp)
return InvalidParameter; return InvalidParameter;
*cachedbmp = heap_alloc_zero(sizeof(GpCachedBitmap)); *cachedbmp = calloc(1, sizeof(GpCachedBitmap));
if(!*cachedbmp) if(!*cachedbmp)
return OutOfMemory; return OutOfMemory;
stat = GdipCloneImage(&(bitmap->image), &(*cachedbmp)->image); stat = GdipCloneImage(&(bitmap->image), &(*cachedbmp)->image);
if(stat != Ok){ if(stat != Ok){
heap_free(*cachedbmp); free(*cachedbmp);
return stat; return stat;
} }
@ -2005,7 +2005,7 @@ GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hicon)
xorstride = lockeddata.Width*4; xorstride = lockeddata.Width*4;
bitssize = (andstride + xorstride) * lockeddata.Height; bitssize = (andstride + xorstride) * lockeddata.Height;
andbits = heap_alloc_zero(bitssize); andbits = calloc(1, bitssize);
if (andbits) if (andbits)
{ {
@ -2027,7 +2027,7 @@ GpStatus WINGDIPAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hicon)
*hicon = CreateIcon(NULL, lockeddata.Width, lockeddata.Height, 1, 32, *hicon = CreateIcon(NULL, lockeddata.Width, lockeddata.Height, 1, 32,
andbits, xorbits); andbits, xorbits);
heap_free(andbits); free(andbits);
} }
else else
stat = OutOfMemory; stat = OutOfMemory;
@ -2046,7 +2046,7 @@ GpStatus WINGDIPAPI GdipDeleteCachedBitmap(GpCachedBitmap *cachedbmp)
return InvalidParameter; return InvalidParameter;
GdipDisposeImage(cachedbmp->image); GdipDisposeImage(cachedbmp->image);
heap_free(cachedbmp); free(cachedbmp);
return Ok; return Ok;
} }
@ -2069,18 +2069,18 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
assert(src->image.type == ImageTypeBitmap); assert(src->image.type == ImageTypeBitmap);
assert(dst->image.type == ImageTypeBitmap); assert(dst->image.type == ImageTypeBitmap);
heap_free(dst->bitmapbits); free(dst->bitmapbits);
heap_free(dst->own_bits); free(dst->own_bits);
DeleteDC(dst->hdc); DeleteDC(dst->hdc);
DeleteObject(dst->hbitmap); DeleteObject(dst->hbitmap);
if (clobber_palette) if (clobber_palette)
{ {
heap_free(dst->image.palette); free(dst->image.palette);
dst->image.palette = src->image.palette; dst->image.palette = src->image.palette;
} }
else else
heap_free(src->image.palette); free(src->image.palette);
dst->image.xres = src->image.xres; dst->image.xres = src->image.xres;
dst->image.yres = src->image.yres; dst->image.yres = src->image.yres;
@ -2095,7 +2095,7 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
if (dst->metadata_reader) if (dst->metadata_reader)
IWICMetadataReader_Release(dst->metadata_reader); IWICMetadataReader_Release(dst->metadata_reader);
dst->metadata_reader = src->metadata_reader; dst->metadata_reader = src->metadata_reader;
heap_free(dst->prop_item); free(dst->prop_item);
dst->prop_item = src->prop_item; dst->prop_item = src->prop_item;
dst->prop_count = src->prop_count; dst->prop_count = src->prop_count;
if (dst->image.decoder) if (dst->image.decoder)
@ -2108,7 +2108,7 @@ static void move_bitmap(GpBitmap *dst, GpBitmap *src, BOOL clobber_palette)
dst->image.format = src->image.format; dst->image.format = src->image.format;
src->image.type = ~0; src->image.type = ~0;
heap_free(src); free(src);
} }
static GpStatus free_image_data(GpImage *image) static GpStatus free_image_data(GpImage *image)
@ -2118,13 +2118,13 @@ static GpStatus free_image_data(GpImage *image)
if (image->type == ImageTypeBitmap) if (image->type == ImageTypeBitmap)
{ {
heap_free(((GpBitmap*)image)->bitmapbits); free(((GpBitmap*)image)->bitmapbits);
heap_free(((GpBitmap*)image)->own_bits); free(((GpBitmap*)image)->own_bits);
DeleteDC(((GpBitmap*)image)->hdc); DeleteDC(((GpBitmap*)image)->hdc);
DeleteObject(((GpBitmap*)image)->hbitmap); DeleteObject(((GpBitmap*)image)->hbitmap);
if (((GpBitmap*)image)->metadata_reader) if (((GpBitmap*)image)->metadata_reader)
IWICMetadataReader_Release(((GpBitmap*)image)->metadata_reader); IWICMetadataReader_Release(((GpBitmap*)image)->metadata_reader);
heap_free(((GpBitmap*)image)->prop_item); free(((GpBitmap*)image)->prop_item);
} }
else if (image->type == ImageTypeMetafile) else if (image->type == ImageTypeMetafile)
METAFILE_Free((GpMetafile *)image); METAFILE_Free((GpMetafile *)image);
@ -2136,7 +2136,7 @@ static GpStatus free_image_data(GpImage *image)
if (image->decoder) if (image->decoder)
IWICBitmapDecoder_Release(image->decoder); IWICBitmapDecoder_Release(image->decoder);
terminate_encoder_wic(image); terminate_encoder_wic(image);
heap_free(image->palette); free(image->palette);
return Ok; return Ok;
} }
@ -2150,7 +2150,7 @@ GpStatus WINGDIPAPI GdipDisposeImage(GpImage *image)
status = free_image_data(image); status = free_image_data(image);
if (status != Ok) return status; if (status != Ok) return status;
image->type = ~0; image->type = ~0;
heap_free(image); free(image);
return Ok; return Ok;
} }
@ -2881,7 +2881,7 @@ GpStatus WINGDIPAPI GdipGetAllPropertyItems(GpImage *image, UINT size,
item_size = propvariant_size(&value); item_size = propvariant_size(&value);
if (item_size) if (item_size)
{ {
item = heap_alloc(item_size + sizeof(*item)); item = malloc(item_size + sizeof(*item));
propvariant_to_item(&value, item, item_size + sizeof(*item), id.uiVal); propvariant_to_item(&value, item, item_size + sizeof(*item), id.uiVal);
buf[i].id = item->id; buf[i].id = item->id;
@ -2891,7 +2891,7 @@ GpStatus WINGDIPAPI GdipGetAllPropertyItems(GpImage *image, UINT size,
memcpy(item_value, item->value, item_size); memcpy(item_value, item->value, item_size);
item_value += item_size; item_value += item_size;
heap_free(item); free(item);
} }
PropVariantClear(&id); PropVariantClear(&id);
@ -3022,7 +3022,7 @@ static void add_property(GpBitmap *bitmap, PropertyItem *item)
if (bitmap->prop_item == NULL) if (bitmap->prop_item == NULL)
{ {
prop_size = prop_count = 0; prop_size = prop_count = 0;
prop_item = heap_alloc_zero(item->length + sizeof(PropertyItem)); prop_item = calloc(1, item->length + sizeof(PropertyItem));
if (!prop_item) return; if (!prop_item) return;
} }
else else
@ -3032,7 +3032,7 @@ static void add_property(GpBitmap *bitmap, PropertyItem *item)
GdipGetPropertySize(&bitmap->image, &prop_size, &prop_count); GdipGetPropertySize(&bitmap->image, &prop_size, &prop_count);
prop_item = heap_alloc_zero(prop_size + item->length + sizeof(PropertyItem)); prop_item = calloc(1, prop_size + item->length + sizeof(PropertyItem));
if (!prop_item) return; if (!prop_item) return;
memcpy(prop_item, bitmap->prop_item, sizeof(PropertyItem) * bitmap->prop_count); memcpy(prop_item, bitmap->prop_item, sizeof(PropertyItem) * bitmap->prop_count);
prop_size -= sizeof(PropertyItem) * bitmap->prop_count; prop_size -= sizeof(PropertyItem) * bitmap->prop_count;
@ -3053,7 +3053,7 @@ static void add_property(GpBitmap *bitmap, PropertyItem *item)
prop_item[prop_count].value = (char *)(prop_item + prop_count + 1) + prop_size; prop_item[prop_count].value = (char *)(prop_item + prop_count + 1) + prop_size;
memcpy(prop_item[prop_count].value, item->value, item->length); memcpy(prop_item[prop_count].value, item->value, item->length);
heap_free(bitmap->prop_item); free(bitmap->prop_item);
bitmap->prop_item = prop_item; bitmap->prop_item = prop_item;
bitmap->prop_count++; bitmap->prop_count++;
} }
@ -3109,10 +3109,10 @@ static PropertyItem *get_property(IWICMetadataReader *reader, const GUID *guid,
if (item_size) if (item_size)
{ {
item_size += sizeof(*item); item_size += sizeof(*item);
item = heap_alloc_zero(item_size); item = calloc(1, item_size);
if (propvariant_to_item(&value, item, item_size, 0) != Ok) if (propvariant_to_item(&value, item, item_size, 0) != Ok)
{ {
heap_free(item); free(item);
item = NULL; item = NULL;
} }
} }
@ -3153,7 +3153,7 @@ static PropertyItem *get_gif_loopcount(IWICMetadataReader *reader)
BYTE *data = appdata->value; BYTE *data = appdata->value;
if (data[0] == 3 && data[1] == 1) if (data[0] == 3 && data[1] == 1)
{ {
loop = heap_alloc_zero(sizeof(*loop) + sizeof(SHORT)); loop = calloc(1, sizeof(*loop) + sizeof(SHORT));
if (loop) if (loop)
{ {
loop->type = PropertyTagTypeShort; loop->type = PropertyTagTypeShort;
@ -3168,8 +3168,8 @@ static PropertyItem *get_gif_loopcount(IWICMetadataReader *reader)
} }
} }
heap_free(appext); free(appext);
heap_free(appdata); free(appdata);
return loop; return loop;
} }
@ -3220,7 +3220,7 @@ static PropertyItem *get_gif_palette(IWICBitmapDecoder *decoder, IWICMetadataRea
UINT i; UINT i;
BYTE *rgb; BYTE *rgb;
pal = heap_alloc_zero(sizeof(*pal) + count * 3); pal = calloc(1, sizeof(*pal) + count * 3);
if (!pal) return NULL; if (!pal) return NULL;
pal->type = PropertyTagTypeByte; pal->type = PropertyTagTypeByte;
pal->id = PropertyTagGlobalPalette; pal->id = PropertyTagGlobalPalette;
@ -3282,7 +3282,7 @@ static void get_gif_frame_property(IWICBitmapFrameDecode *frame, const GUID *for
else if (prop->type == PropertyTagTypeShort && prop->length == 2) else if (prop->type == PropertyTagTypeShort && prop->length == 2)
*value = *(SHORT *)prop->value; *value = *(SHORT *)prop->value;
heap_free(prop); free(prop);
} }
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
@ -3303,7 +3303,7 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
PropertyItem *transparent_idx = NULL, *loop = NULL, *palette = NULL; PropertyItem *transparent_idx = NULL, *loop = NULL, *palette = NULL;
IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
delay = heap_alloc_zero(sizeof(*delay) + frame_count * sizeof(LONG)); delay = calloc(1, sizeof(*delay) + frame_count * sizeof(LONG));
if (delay) if (delay)
{ {
LONG *value; LONG *value;
@ -3360,7 +3360,7 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
if (!loop) if (!loop)
{ {
loop = heap_alloc_zero(sizeof(*loop) + sizeof(SHORT)); loop = calloc(1, sizeof(*loop) + sizeof(SHORT));
if (loop) if (loop)
{ {
loop->type = PropertyTagTypeShort; loop->type = PropertyTagTypeShort;
@ -3377,11 +3377,11 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
if (palette) add_property(bitmap, palette); if (palette) add_property(bitmap, palette);
if (background) add_property(bitmap, background); if (background) add_property(bitmap, background);
heap_free(delay); free(delay);
heap_free(comment); free(comment);
heap_free(loop); free(loop);
heap_free(palette); free(palette);
heap_free(background); free(background);
/* Win7 gdiplus always returns transparent color index from frame 0 */ /* Win7 gdiplus always returns transparent color index from frame 0 */
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
@ -3409,7 +3409,7 @@ static void gif_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
} }
if (transparent_idx) add_property(bitmap, transparent_idx); if (transparent_idx) add_property(bitmap, transparent_idx);
heap_free(transparent_idx); free(transparent_idx);
IWICBitmapFrameDecode_Release(frame); IWICBitmapFrameDecode_Release(frame);
} }
@ -3422,10 +3422,10 @@ static PropertyItem* create_prop(PROPID propid, PROPVARIANT* value)
if (item_size) if (item_size)
{ {
item_size += sizeof(*item); item_size += sizeof(*item);
item = heap_alloc_zero(item_size); item = calloc(1, item_size);
if (propvariant_to_item(value, item, item_size, propid) != Ok) if (propvariant_to_item(value, item, item_size, propid) != Ok)
{ {
heap_free(item); free(item);
item = NULL; item = NULL;
} }
} }
@ -3476,7 +3476,7 @@ static HRESULT png_read_text(IWICMetadataReader *reader, GpBitmap *bitmap, BOOL
}; };
if (*seen_text == NULL) if (*seen_text == NULL)
*seen_text = heap_alloc_zero(sizeof(BOOL) * ARRAY_SIZE(keywords)); *seen_text = calloc(ARRAY_SIZE(keywords), sizeof(BOOL));
if (*seen_text == NULL) if (*seen_text == NULL)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3497,7 +3497,7 @@ static HRESULT png_read_text(IWICMetadataReader *reader, GpBitmap *bitmap, BOOL
item = create_prop(keywords[i].propid, &value); item = create_prop(keywords[i].propid, &value);
if (item) if (item)
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
} }
} }
@ -3512,7 +3512,7 @@ static HRESULT png_read_gamma(IWICMetadataReader *reader, GpBitmap *bitmap)
PropertyItem* item; PropertyItem* item;
ULONG *rational; ULONG *rational;
item = heap_alloc_zero(sizeof(*item) + sizeof(ULONG) * 2); item = calloc(1, sizeof(*item) + sizeof(ULONG) * 2);
if (!item) if (!item)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3523,7 +3523,7 @@ static HRESULT png_read_gamma(IWICMetadataReader *reader, GpBitmap *bitmap)
rational[0] = 100000; rational[0] = 100000;
rational[1] = get_ulong_by_index(reader, 0); rational[1] = get_ulong_by_index(reader, 0);
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
return S_OK; return S_OK;
} }
@ -3533,7 +3533,7 @@ static HRESULT png_read_whitepoint(IWICMetadataReader *reader, GpBitmap *bitmap)
PropertyItem* item; PropertyItem* item;
ULONG *rational; ULONG *rational;
item = heap_alloc_zero(sizeof(*item) + sizeof(ULONG) * 4); item = calloc(1, sizeof(*item) + sizeof(ULONG) * 4);
if (!item) if (!item)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3546,7 +3546,7 @@ static HRESULT png_read_whitepoint(IWICMetadataReader *reader, GpBitmap *bitmap)
rational[2] = get_ulong_by_index(reader, 1); rational[2] = get_ulong_by_index(reader, 1);
rational[3] = 100000; rational[3] = 100000;
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
return S_OK; return S_OK;
} }
@ -3556,7 +3556,7 @@ static HRESULT png_read_chromaticity(IWICMetadataReader *reader, GpBitmap *bitma
PropertyItem* item; PropertyItem* item;
ULONG *rational; ULONG *rational;
item = heap_alloc_zero(sizeof(*item) + sizeof(ULONG) * 12); item = calloc(1, sizeof(*item) + sizeof(ULONG) * 12);
if (!item) if (!item)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3577,7 +3577,7 @@ static HRESULT png_read_chromaticity(IWICMetadataReader *reader, GpBitmap *bitma
rational[10] = get_ulong_by_index(reader, 7); rational[10] = get_ulong_by_index(reader, 7);
rational[11] = 100000; rational[11] = 100000;
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
return S_OK; return S_OK;
} }
@ -3608,7 +3608,7 @@ static HRESULT png_read_time(IWICMetadataReader *reader, GpBitmap *bitmap)
} }
item_size = 20; item_size = 20;
item = heap_alloc_zero(sizeof(*item) + item_size); item = calloc(1, sizeof(*item) + item_size);
if (!item) if (!item)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -3620,7 +3620,7 @@ static HRESULT png_read_time(IWICMetadataReader *reader, GpBitmap *bitmap)
datetime[0], datetime[1], datetime[2], datetime[3], datetime[4], datetime[5]); datetime[0], datetime[1], datetime[2], datetime[3], datetime[4], datetime[5]);
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
return S_OK; return S_OK;
} }
@ -3638,7 +3638,7 @@ static HRESULT png_read_histogram(IWICMetadataReader *reader, GpBitmap *bitmap)
item = create_prop(PropertyTagPaletteHistogram, &value); item = create_prop(PropertyTagPaletteHistogram, &value);
if (item) if (item)
add_property(bitmap, item); add_property(bitmap, item);
heap_free(item); free(item);
PropVariantClear(&value); PropVariantClear(&value);
@ -3655,15 +3655,15 @@ static HRESULT png_add_unit_properties(IWICBitmapFrameDecode *frame, GpBitmap *b
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
unit = heap_alloc_zero(sizeof(*unit) + 1); unit = calloc(1, sizeof(*unit) + 1);
unitX = heap_alloc_zero(sizeof(*unitX) + 4); unitX = calloc(1, sizeof(*unitX) + 4);
unitY = heap_alloc_zero(sizeof(*unitY) + 4); unitY = calloc(1, sizeof(*unitY) + 4);
if (!unit || !unitX || !unitY) if (!unit || !unitX || !unitY)
{ {
heap_free(unit); free(unit);
heap_free(unitX); free(unitX);
heap_free(unitY); free(unitY);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
@ -3673,7 +3673,7 @@ static HRESULT png_add_unit_properties(IWICBitmapFrameDecode *frame, GpBitmap *b
unit->value = unit + 1; unit->value = unit + 1;
*(BYTE *)unit->value = 1; *(BYTE *)unit->value = 1;
add_property(bitmap, unit); add_property(bitmap, unit);
heap_free(unit); free(unit);
unitX->type = PropertyTagTypeLong; unitX->type = PropertyTagTypeLong;
unitX->id = PropertyTagPixelPerUnitX; unitX->id = PropertyTagPixelPerUnitX;
@ -3681,7 +3681,7 @@ static HRESULT png_add_unit_properties(IWICBitmapFrameDecode *frame, GpBitmap *b
unitX->value = unitX + 1; unitX->value = unitX + 1;
*(ULONG *)unitX->value = (dpiX == 96.0) ? 0 : gdip_round(dpiX / 0.0254); *(ULONG *)unitX->value = (dpiX == 96.0) ? 0 : gdip_round(dpiX / 0.0254);
add_property(bitmap, unitX); add_property(bitmap, unitX);
heap_free(unitX); free(unitX);
unitY->type = PropertyTagTypeLong; unitY->type = PropertyTagTypeLong;
unitY->id = PropertyTagPixelPerUnitY; unitY->id = PropertyTagPixelPerUnitY;
@ -3689,7 +3689,7 @@ static HRESULT png_add_unit_properties(IWICBitmapFrameDecode *frame, GpBitmap *b
unitY->value = unitY + 1; unitY->value = unitY + 1;
*(ULONG *)unitY->value = (dpiY == 96.0) ? 0 : gdip_round(dpiY / 0.0254); *(ULONG *)unitY->value = (dpiY == 96.0) ? 0 : gdip_round(dpiY / 0.0254);
add_property(bitmap, unitY); add_property(bitmap, unitY);
heap_free(unitY); free(unitY);
return S_OK; return S_OK;
} }
@ -3780,7 +3780,7 @@ static void png_metadata_reader(GpBitmap *bitmap, IWICBitmapDecoder *decoder, UI
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
heap_free(seen_text); free(seen_text);
png_add_unit_properties(frame, bitmap); png_add_unit_properties(frame, bitmap);
@ -3953,7 +3953,7 @@ static GpStatus decode_frame_wic(IWICBitmapDecoder *decoder, BOOL force_conversi
IWICBitmapDecoder_AddRef(decoder); IWICBitmapDecoder_AddRef(decoder);
if (palette) if (palette)
{ {
heap_free(bitmap->image.palette); free(bitmap->image.palette);
bitmap->image.palette = palette; bitmap->image.palette = palette;
} }
else else
@ -4011,7 +4011,7 @@ static GpStatus select_frame_wic(GpImage *image, UINT active_frame)
body_offset = RTL_SIZEOF_THROUGH_FIELD(GpImage, lock); body_offset = RTL_SIZEOF_THROUGH_FIELD(GpImage, lock);
memcpy((char *)image + body_offset, (char *)new_image + body_offset, obj_size - body_offset); memcpy((char *)image + body_offset, (char *)new_image + body_offset, obj_size - body_offset);
new_image->type = ~0; new_image->type = ~0;
heap_free(new_image); free(new_image);
return Ok; return Ok;
} }
@ -4042,14 +4042,14 @@ static HRESULT blit_gif_frame(GpBitmap *bitmap, IWICBitmapFrameDecode *frame, BO
if(FAILED(hr)) if(FAILED(hr))
return hr; return hr;
new_bits = heap_alloc_zero(width*height*4); new_bits = calloc(width * height, 4);
if(!new_bits) if(!new_bits)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
hr = IWICBitmapSource_CopyPixels(source, NULL, width*4, width*height*4, new_bits); hr = IWICBitmapSource_CopyPixels(source, NULL, width*4, width*height*4, new_bits);
IWICBitmapSource_Release(source); IWICBitmapSource_Release(source);
if(FAILED(hr)) { if(FAILED(hr)) {
heap_free(new_bits); free(new_bits);
return hr; return hr;
} }
@ -4062,7 +4062,7 @@ static HRESULT blit_gif_frame(GpBitmap *bitmap, IWICBitmapFrameDecode *frame, BO
*dst = *src; *dst = *src;
} }
} }
heap_free(new_bits); free(new_bits);
return hr; return hr;
} }
@ -4287,7 +4287,7 @@ static GpStatus decode_image_gif(IStream* stream, GpImage **image)
return status; return status;
if(frame_count > 1) { if(frame_count > 1) {
heap_free((*image)->palette); free((*image)->palette);
(*image)->palette = NULL; (*image)->palette = NULL;
} }
return Ok; return Ok;
@ -4338,18 +4338,18 @@ static GpStatus load_wmf(IStream *stream, GpMetafile **metafile)
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
if (FAILED(hr)) return hresult_to_status(hr); if (FAILED(hr)) return hresult_to_status(hr);
buf = heap_alloc(mh.mtSize * 2); buf = malloc(mh.mtSize * 2);
if (!buf) return OutOfMemory; if (!buf) return OutOfMemory;
hr = IStream_Read(stream, buf, mh.mtSize * 2, &size); hr = IStream_Read(stream, buf, mh.mtSize * 2, &size);
if (hr != S_OK || size != mh.mtSize * 2) if (hr != S_OK || size != mh.mtSize * 2)
{ {
heap_free(buf); free(buf);
return GenericError; return GenericError;
} }
hmf = SetMetaFileBitsEx(mh.mtSize * 2, buf); hmf = SetMetaFileBitsEx(mh.mtSize * 2, buf);
heap_free(buf); free(buf);
if (!hmf) if (!hmf)
return GenericError; return GenericError;
@ -4400,18 +4400,18 @@ static GpStatus load_emf(IStream *stream, GpMetafile **metafile)
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
if (FAILED(hr)) return hresult_to_status(hr); if (FAILED(hr)) return hresult_to_status(hr);
buf = heap_alloc(emh.nBytes); buf = malloc(emh.nBytes);
if (!buf) return OutOfMemory; if (!buf) return OutOfMemory;
hr = IStream_Read(stream, buf, emh.nBytes, &size); hr = IStream_Read(stream, buf, emh.nBytes, &size);
if (hr != S_OK || size != emh.nBytes) if (hr != S_OK || size != emh.nBytes)
{ {
heap_free(buf); free(buf);
return GenericError; return GenericError;
} }
hemf = SetEnhMetaFileBits(emh.nBytes, buf); hemf = SetEnhMetaFileBits(emh.nBytes, buf);
heap_free(buf); free(buf);
if (!hemf) if (!hemf)
return GenericError; return GenericError;
@ -5057,10 +5057,10 @@ GpStatus WINGDIPAPI GdipSetImagePalette(GpImage *image,
if(!image || !palette || palette->Count > 256) if(!image || !palette || palette->Count > 256)
return InvalidParameter; return InvalidParameter;
new_palette = heap_alloc_zero(2 * sizeof(UINT) + palette->Count * sizeof(ARGB)); new_palette = calloc(1, 2 * sizeof(UINT) + palette->Count * sizeof(ARGB));
if (!new_palette) return OutOfMemory; if (!new_palette) return OutOfMemory;
heap_free(image->palette); free(image->palette);
image->palette = new_palette; image->palette = new_palette;
image->palette->Flags = palette->Flags; image->palette->Flags = palette->Flags;
image->palette->Count = palette->Count; image->palette->Count = palette->Count;
@ -5541,7 +5541,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
if (!num_palette_entries) if (!num_palette_entries)
num_palette_entries = 1 << pbmi->bmiHeader.biBitCount; num_palette_entries = 1 << pbmi->bmiHeader.biBitCount;
palette = heap_alloc_zero(sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries-1)); palette = calloc(1, sizeof(ColorPalette) + sizeof(ARGB) * (num_palette_entries - 1));
if (!palette) if (!palette)
retval = OutOfMemory; retval = OutOfMemory;
else else
@ -5558,7 +5558,7 @@ GpStatus WINGDIPAPI GdipCreateBitmapFromHBITMAP(HBITMAP hbm, HPALETTE hpal, GpBi
retval = GdipSetImagePalette(&(*bitmap)->image, palette); retval = GdipSetImagePalette(&(*bitmap)->image, palette);
} }
heap_free(palette); free(palette);
} }
if (retval != Ok) if (retval != Ok)
@ -6076,7 +6076,7 @@ GpStatus WINGDIPAPI GdipInitializePalette(ColorPalette *palette,
else else
status = GenericError; status = GenericError;
heap_free(wic_palette); free(wic_palette);
return status; return status;
} }

View file

@ -45,7 +45,7 @@ GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imagea
{ {
remap_tables[i].enabled = TRUE; remap_tables[i].enabled = TRUE;
remap_tables[i].mapsize = imageattr->colorremaptables[i].mapsize; 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) if (remap_tables[i].colormap)
{ {
@ -73,7 +73,7 @@ GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imagea
if (stat != Ok) if (stat != Ok)
{ {
for (i=0; i<ColorAdjustTypeCount; i++) for (i=0; i<ColorAdjustTypeCount; i++)
heap_free(remap_tables[i].colormap); free(remap_tables[i].colormap);
} }
return stat; return stat;
@ -84,8 +84,8 @@ GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
if(!imageattr) if(!imageattr)
return InvalidParameter; return InvalidParameter;
*imageattr = heap_alloc_zero(sizeof(GpImageAttributes)); *imageattr = calloc(1, sizeof(GpImageAttributes));
if(!*imageattr) return OutOfMemory; if(!*imageattr) return OutOfMemory;
(*imageattr)->wrap = WrapModeClamp; (*imageattr)->wrap = WrapModeClamp;
@ -104,9 +104,9 @@ GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
return InvalidParameter; return InvalidParameter;
for (i=0; i<ColorAdjustTypeCount; i++) for (i=0; i<ColorAdjustTypeCount; i++)
heap_free(imageattr->colorremaptables[i].colormap); free(imageattr->colorremaptables[i].colormap);
heap_free(imageattr); free(imageattr);
return Ok; return Ok;
} }
@ -271,21 +271,21 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
if(!map || !mapSize) if(!map || !mapSize)
return InvalidParameter; return InvalidParameter;
new_map = heap_alloc_zero(sizeof(*map) * mapSize); new_map = malloc(sizeof(*map) * mapSize);
if (!new_map) if (!new_map)
return OutOfMemory; return OutOfMemory;
memcpy(new_map, map, sizeof(*map) * mapSize); 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].mapsize = mapSize;
imageAttr->colorremaptables[type].colormap = new_map; imageAttr->colorremaptables[type].colormap = new_map;
} }
else else
{ {
heap_free(imageAttr->colorremaptables[type].colormap); free(imageAttr->colorremaptables[type].colormap);
imageAttr->colorremaptables[type].colormap = NULL; imageAttr->colorremaptables[type].colormap = NULL;
} }

View file

@ -64,8 +64,8 @@ GpStatus WINGDIPAPI GdipCreateMatrix2(REAL m11, REAL m12, REAL m21, REAL m22,
if(!matrix) if(!matrix)
return InvalidParameter; return InvalidParameter;
*matrix = heap_alloc_zero(sizeof(GpMatrix)); *matrix = malloc(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory; if(!*matrix) return OutOfMemory;
/* first row */ /* first row */
(*matrix)->matrix[0] = m11; (*matrix)->matrix[0] = m11;
@ -125,8 +125,8 @@ GpStatus WINGDIPAPI GdipCloneMatrix(GpMatrix *matrix, GpMatrix **clone)
if(!matrix || !clone) if(!matrix || !clone)
return InvalidParameter; return InvalidParameter;
*clone = heap_alloc_zero(sizeof(GpMatrix)); *clone = malloc(sizeof(GpMatrix));
if(!*clone) return OutOfMemory; if(!*clone) return OutOfMemory;
**clone = *matrix; **clone = *matrix;
@ -140,8 +140,8 @@ GpStatus WINGDIPAPI GdipCreateMatrix(GpMatrix **matrix)
if(!matrix) if(!matrix)
return InvalidParameter; return InvalidParameter;
*matrix = heap_alloc_zero(sizeof(GpMatrix)); *matrix = malloc(sizeof(GpMatrix));
if(!*matrix) return OutOfMemory; if(!*matrix) return OutOfMemory;
(*matrix)->matrix[0] = 1.0; (*matrix)->matrix[0] = 1.0;
(*matrix)->matrix[1] = 0.0; (*matrix)->matrix[1] = 0.0;
@ -160,7 +160,7 @@ GpStatus WINGDIPAPI GdipDeleteMatrix(GpMatrix *matrix)
if(!matrix) if(!matrix)
return InvalidParameter; return InvalidParameter;
heap_free(matrix); free(matrix);
return Ok; return Ok;
} }
@ -396,7 +396,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
if(count <= 0) if(count <= 0)
return InvalidParameter; return InvalidParameter;
ptsF = heap_alloc_zero(sizeof(GpPointF) * count); ptsF = malloc(sizeof(GpPointF) * count);
if(!ptsF) if(!ptsF)
return OutOfMemory; return OutOfMemory;
@ -412,7 +412,7 @@ GpStatus WINGDIPAPI GdipTransformMatrixPointsI(GpMatrix *matrix, GpPoint *pts, I
pts[i].X = gdip_round(ptsF[i].X); pts[i].X = gdip_round(ptsF[i].X);
pts[i].Y = gdip_round(ptsF[i].Y); pts[i].Y = gdip_round(ptsF[i].Y);
} }
heap_free(ptsF); free(ptsF);
return ret; return ret;
} }
@ -476,7 +476,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
if(count <= 0) if(count <= 0)
return InvalidParameter; return InvalidParameter;
ptsF = heap_alloc_zero(sizeof(GpPointF) * count); ptsF = malloc(sizeof(GpPointF) * count);
if(!ptsF) if(!ptsF)
return OutOfMemory; return OutOfMemory;
@ -492,7 +492,7 @@ GpStatus WINGDIPAPI GdipVectorTransformMatrixPointsI(GpMatrix *matrix, GpPoint *
pts[i].X = gdip_round(ptsF[i].X); pts[i].X = gdip_round(ptsF[i].X);
pts[i].Y = gdip_round(ptsF[i].Y); pts[i].Y = gdip_round(ptsF[i].Y);
} }
heap_free(ptsF); free(ptsF);
return ret; return ret;
} }

View file

@ -688,7 +688,7 @@ void METAFILE_Free(GpMetafile *metafile)
{ {
unsigned int i; unsigned int i;
heap_free(metafile->comment_data); free(metafile->comment_data);
DeleteEnhMetaFile(CloseEnhMetaFile(metafile->record_dc)); DeleteEnhMetaFile(CloseEnhMetaFile(metafile->record_dc));
if (!metafile->preserve_hemf) if (!metafile->preserve_hemf)
DeleteEnhMetaFile(metafile->hemf); DeleteEnhMetaFile(metafile->hemf);
@ -721,7 +721,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, EmfPlusRecordType
if (!metafile->comment_data_size) if (!metafile->comment_data_size)
{ {
DWORD data_size = max(256, size * 2 + 4); DWORD data_size = max(256, size * 2 + 4);
metafile->comment_data = heap_alloc_zero(data_size); metafile->comment_data = calloc(1, data_size);
if (!metafile->comment_data) if (!metafile->comment_data)
return OutOfMemory; return OutOfMemory;
@ -737,7 +737,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, EmfPlusRecordType
if (size_needed > metafile->comment_data_size) if (size_needed > metafile->comment_data_size)
{ {
DWORD data_size = size_needed * 2; DWORD data_size = size_needed * 2;
BYTE *new_data = heap_alloc_zero(data_size); BYTE *new_data = calloc(1, data_size);
if (!new_data) if (!new_data)
return OutOfMemory; return OutOfMemory;
@ -745,7 +745,7 @@ static GpStatus METAFILE_AllocateRecord(GpMetafile *metafile, EmfPlusRecordType
memcpy(new_data, metafile->comment_data, metafile->comment_data_length); memcpy(new_data, metafile->comment_data, metafile->comment_data_length);
metafile->comment_data_size = data_size; metafile->comment_data_size = data_size;
heap_free(metafile->comment_data); free(metafile->comment_data);
metafile->comment_data = new_data; metafile->comment_data = new_data;
} }
@ -1682,7 +1682,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
metafile->hemf = CloseEnhMetaFile(metafile->record_dc); metafile->hemf = CloseEnhMetaFile(metafile->record_dc);
metafile->record_dc = NULL; metafile->record_dc = NULL;
heap_free(metafile->comment_data); free(metafile->comment_data);
metafile->comment_data = NULL; metafile->comment_data = NULL;
metafile->comment_data_size = 0; metafile->comment_data_size = 0;
@ -1719,7 +1719,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
bounds_rc.bottom = ceilf(metafile->auto_frame_max.Y * y_scale); bounds_rc.bottom = ceilf(metafile->auto_frame_max.Y * y_scale);
buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL); buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL);
buffer = heap_alloc(buffer_size); buffer = malloc(buffer_size);
if (buffer) if (buffer)
{ {
HENHMETAFILE new_hemf; HENHMETAFILE new_hemf;
@ -1738,7 +1738,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
else else
stat = OutOfMemory; stat = OutOfMemory;
heap_free(buffer); free(buffer);
} }
else else
stat = OutOfMemory; stat = OutOfMemory;
@ -1762,7 +1762,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL); buffer_size = GetEnhMetaFileBits(metafile->hemf, 0, NULL);
buffer = heap_alloc(buffer_size); buffer = malloc(buffer_size);
if (buffer) if (buffer)
{ {
HRESULT hr; HRESULT hr;
@ -1774,7 +1774,7 @@ GpStatus METAFILE_GraphicsDeleted(GpMetafile* metafile)
if (FAILED(hr)) if (FAILED(hr))
stat = hresult_to_status(hr); stat = hresult_to_status(hr);
heap_free(buffer); free(buffer);
} }
else else
stat = OutOfMemory; stat = OutOfMemory;
@ -2040,8 +2040,8 @@ static GpStatus metafile_deserialize_path(const BYTE *record_data, UINT data_siz
return status; return status;
(*path)->pathdata.Count = data->PathPointCount; (*path)->pathdata.Count = data->PathPointCount;
(*path)->pathdata.Points = GdipAlloc(data->PathPointCount * sizeof(*(*path)->pathdata.Points)); (*path)->pathdata.Points = malloc(data->PathPointCount * sizeof(*(*path)->pathdata.Points));
(*path)->pathdata.Types = GdipAlloc(data->PathPointCount * sizeof(*(*path)->pathdata.Types)); (*path)->pathdata.Types = malloc(data->PathPointCount * sizeof(*(*path)->pathdata.Types));
(*path)->datalen = (*path)->pathdata.Count; (*path)->datalen = (*path)->pathdata.Count;
if (!(*path)->pathdata.Points || !(*path)->pathdata.Types) if (!(*path)->pathdata.Points || !(*path)->pathdata.Types)
@ -2093,14 +2093,14 @@ static GpStatus metafile_read_region_node(struct memory_buffer *mbuf, GpRegion *
{ {
region_element *left, *right; region_element *left, *right;
left = heap_alloc_zero(sizeof(*left)); left = calloc(1, sizeof(*left));
if (!left) if (!left)
return OutOfMemory; return OutOfMemory;
right = heap_alloc_zero(sizeof(*right)); right = calloc(1, sizeof(*right));
if (!right) if (!right)
{ {
heap_free(left); free(left);
return OutOfMemory; return OutOfMemory;
} }
@ -2117,8 +2117,8 @@ static GpStatus metafile_read_region_node(struct memory_buffer *mbuf, GpRegion *
} }
} }
heap_free(left); free(left);
heap_free(right); free(right);
return status; return status;
} }
case RegionDataRect: case RegionDataRect:
@ -2707,14 +2707,14 @@ static GpStatus METAFILE_PlaybackObject(GpMetafile *metafile, UINT flags, UINT d
if (data_size < data->Length * sizeof(WCHAR)) if (data_size < data->Length * sizeof(WCHAR))
return InvalidParameter; return InvalidParameter;
if (!(familyname = GdipAlloc((data->Length + 1) * sizeof(*familyname)))) if (!(familyname = malloc((data->Length + 1) * sizeof(*familyname))))
return OutOfMemory; return OutOfMemory;
memcpy(familyname, data->FamilyName, data->Length * sizeof(*familyname)); memcpy(familyname, data->FamilyName, data->Length * sizeof(*familyname));
familyname[data->Length] = 0; familyname[data->Length] = 0;
status = GdipCreateFontFamilyFromName(familyname, NULL, &family); status = GdipCreateFontFamilyFromName(familyname, NULL, &family);
GdipFree(familyname); free(familyname);
/* If a font family cannot be created from family name, native /* If a font family cannot be created from family name, native
falls back to a sans serif font. */ falls back to a sans serif font. */
@ -2785,7 +2785,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
/* regular EMF record */ /* regular EMF record */
if (metafile->playback_dc) if (metafile->playback_dc)
{ {
ENHMETARECORD *record = heap_alloc_zero(dataSize + 8); ENHMETARECORD *record = calloc(1, dataSize + 8);
if (record) if (record)
{ {
@ -2800,7 +2800,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
record, metafile->handle_count) == 0) record, metafile->handle_count) == 0)
ERR("PlayEnhMetaFileRecord failed\n"); ERR("PlayEnhMetaFileRecord failed\n");
heap_free(record); free(record);
} }
else else
return OutOfMemory; return OutOfMemory;
@ -2871,7 +2871,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
EmfPlusRect *int_rects = (EmfPlusRect*)(record+1); EmfPlusRect *int_rects = (EmfPlusRect*)(record+1);
int i; int i;
rects = temp_rects = heap_alloc_zero(sizeof(GpRectF) * record->Count); rects = temp_rects = calloc(record->Count, sizeof(GpRectF));
if (rects) if (rects)
{ {
for (i=0; i<record->Count; i++) for (i=0; i<record->Count; i++)
@ -2895,7 +2895,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
} }
GdipDeleteBrush(temp_brush); GdipDeleteBrush(temp_brush);
heap_free(temp_rects); free(temp_rects);
return stat; return stat;
} }
@ -3050,14 +3050,14 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
GpRectF scaled_srcrect; GpRectF scaled_srcrect;
GpMatrix transform; GpMatrix transform;
cont = heap_alloc_zero(sizeof(*cont)); cont = calloc(1, sizeof(*cont));
if (!cont) if (!cont)
return OutOfMemory; return OutOfMemory;
stat = GdipCloneRegion(metafile->clip, &cont->clip); stat = GdipCloneRegion(metafile->clip, &cont->clip);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(cont); free(cont);
return stat; return stat;
} }
@ -3066,7 +3066,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
if (stat != Ok) if (stat != Ok)
{ {
GdipDeleteRegion(cont->clip); GdipDeleteRegion(cont->clip);
heap_free(cont); free(cont);
return stat; return stat;
} }
@ -3104,14 +3104,14 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
EmfPlusContainerRecord *record = (EmfPlusContainerRecord*)header; EmfPlusContainerRecord *record = (EmfPlusContainerRecord*)header;
container* cont; container* cont;
cont = heap_alloc_zero(sizeof(*cont)); cont = calloc(1, sizeof(*cont));
if (!cont) if (!cont)
return OutOfMemory; return OutOfMemory;
stat = GdipCloneRegion(metafile->clip, &cont->clip); stat = GdipCloneRegion(metafile->clip, &cont->clip);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(cont); free(cont);
return stat; return stat;
} }
@ -3123,7 +3123,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
if (stat != Ok) if (stat != Ok)
{ {
GdipDeleteRegion(cont->clip); GdipDeleteRegion(cont->clip);
heap_free(cont); free(cont);
return stat; return stat;
} }
@ -3170,7 +3170,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
{ {
list_remove(&cont2->entry); list_remove(&cont2->entry);
GdipDeleteRegion(cont2->clip); GdipDeleteRegion(cont2->clip);
heap_free(cont2); free(cont2);
} }
if (type == BEGIN_CONTAINER) if (type == BEGIN_CONTAINER)
@ -3185,7 +3185,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
list_remove(&cont->entry); list_remove(&cont->entry);
GdipDeleteRegion(cont->clip); GdipDeleteRegion(cont->clip);
heap_free(cont); free(cont);
} }
break; break;
@ -3399,7 +3399,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
if (flags & (0x800 | 0x4000)) if (flags & (0x800 | 0x4000))
{ {
GpPointF *points = GdipAlloc(fill->Count * sizeof(*points)); GpPointF *points = malloc(fill->Count * sizeof(*points));
if (points) if (points)
{ {
if (flags & 0x800) /* P */ if (flags & 0x800) /* P */
@ -3421,7 +3421,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
stat = GdipFillClosedCurve2(real_metafile->playback_graphics, brush, stat = GdipFillClosedCurve2(real_metafile->playback_graphics, brush,
points, fill->Count, fill->Tension, mode); points, fill->Count, fill->Tension, mode);
GdipFree(points); free(points);
} }
else else
stat = OutOfMemory; stat = OutOfMemory;
@ -3613,7 +3613,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
{ {
DWORD i; DWORD i;
rects = GdipAlloc(draw->Count * sizeof(*rects)); rects = malloc(draw->Count * sizeof(*rects));
if (!rects) if (!rects)
return OutOfMemory; return OutOfMemory;
@ -3628,7 +3628,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
stat = GdipDrawRectangles(real_metafile->playback_graphics, real_metafile->objtable[pen].u.pen, stat = GdipDrawRectangles(real_metafile->playback_graphics, real_metafile->objtable[pen].u.pen,
rects ? rects : (GpRectF *)draw->RectData.rectF, draw->Count); rects ? rects : (GpRectF *)draw->RectData.rectF, draw->Count);
GdipFree(rects); free(rects);
return stat; return stat;
} }
case EmfPlusRecordTypeDrawDriverString: case EmfPlusRecordTypeDrawDriverString:
@ -3692,7 +3692,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
if (draw->MatrixPresent) if (draw->MatrixPresent)
alloc_size += sizeof(*matrix); alloc_size += sizeof(*matrix);
positions = alignedmem = heap_alloc(alloc_size); positions = alignedmem = malloc(alloc_size);
if (!positions) if (!positions)
{ {
GdipDeleteBrush((GpBrush*)solidfill); GdipDeleteBrush((GpBrush*)solidfill);
@ -3712,7 +3712,7 @@ GpStatus WINGDIPAPI GdipPlayMetafileRecord(GDIPCONST GpMetafile *metafile,
draw->DriverStringOptionsFlags, matrix); draw->DriverStringOptionsFlags, matrix);
GdipDeleteBrush((GpBrush*)solidfill); GdipDeleteBrush((GpBrush*)solidfill);
heap_free(alignedmem); free(alignedmem);
return stat; return stat;
} }
@ -3948,7 +3948,7 @@ GpStatus WINGDIPAPI GdipEnumerateMetafileSrcRectDestPoints(GpGraphics *graphics,
container* cont = LIST_ENTRY(list_head(&real_metafile->containers), container, entry); container* cont = LIST_ENTRY(list_head(&real_metafile->containers), container, entry);
list_remove(&cont->entry); list_remove(&cont->entry);
GdipDeleteRegion(cont->clip); GdipDeleteRegion(cont->clip);
heap_free(cont); free(cont);
} }
GdipEndContainer(graphics, state); GdipEndContainer(graphics, state);
@ -4248,7 +4248,7 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromEmf(HENHMETAFILE hemf, BOOL delete,
if (stat != Ok) if (stat != Ok)
return stat; return stat;
*metafile = heap_alloc_zero(sizeof(GpMetafile)); *metafile = calloc(1, sizeof(GpMetafile));
if (!*metafile) if (!*metafile)
return OutOfMemory; return OutOfMemory;
@ -4296,11 +4296,11 @@ GpStatus WINGDIPAPI GdipCreateMetafileFromWmf(HMETAFILE hwmf, BOOL delete,
read = GetMetaFileBitsEx(hwmf, 0, NULL); read = GetMetaFileBitsEx(hwmf, 0, NULL);
if(!read) if(!read)
return GenericError; return GenericError;
copy = heap_alloc_zero(read); copy = malloc(read);
GetMetaFileBitsEx(hwmf, read, copy); GetMetaFileBitsEx(hwmf, read, copy);
hemf = SetWinMetaFileBits(read, copy, NULL, NULL); hemf = SetWinMetaFileBits(read, copy, NULL, NULL);
heap_free(copy); free(copy);
/* FIXME: We should store and use hwmf instead of converting to hemf */ /* FIXME: We should store and use hwmf instead of converting to hemf */
retval = GdipCreateMetafileFromEmf(hemf, TRUE, metafile); retval = GdipCreateMetafileFromEmf(hemf, TRUE, metafile);
@ -4516,7 +4516,7 @@ GpStatus WINGDIPAPI GdipRecordMetafileFileName(GDIPCONST WCHAR* fileName,
if (!record_dc) if (!record_dc)
return GenericError; return GenericError;
*metafile = heap_alloc_zero(sizeof(GpMetafile)); *metafile = calloc(1, sizeof(GpMetafile));
if(!*metafile) if(!*metafile)
{ {
DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); DeleteEnhMetaFile(CloseEnhMetaFile(record_dc));
@ -4557,7 +4557,7 @@ GpStatus WINGDIPAPI GdipRecordMetafileFileName(GDIPCONST WCHAR* fileName,
if (stat != Ok) if (stat != Ok)
{ {
DeleteEnhMetaFile(CloseEnhMetaFile(record_dc)); DeleteEnhMetaFile(CloseEnhMetaFile(record_dc));
heap_free(*metafile); free(*metafile);
*metafile = NULL; *metafile = NULL;
return OutOfMemory; return OutOfMemory;
} }

View file

@ -40,14 +40,14 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
if(!iterator) if(!iterator)
return InvalidParameter; return InvalidParameter;
*iterator = heap_alloc_zero(sizeof(GpPathIterator)); *iterator = calloc(1, sizeof(GpPathIterator));
if(!*iterator) return OutOfMemory; if(!*iterator) return OutOfMemory;
if(path){ if(path){
size = path->pathdata.Count; size = path->pathdata.Count;
(*iterator)->pathdata.Types = heap_alloc_zero(size); (*iterator)->pathdata.Types = malloc(size);
(*iterator)->pathdata.Points = heap_alloc_zero(size * sizeof(PointF)); (*iterator)->pathdata.Points = malloc(size * sizeof(PointF));
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size); memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF)); memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
@ -73,9 +73,9 @@ GpStatus WINGDIPAPI GdipDeletePathIter(GpPathIterator *iter)
if(!iter) if(!iter)
return InvalidParameter; return InvalidParameter;
heap_free(iter->pathdata.Types); free(iter->pathdata.Types);
heap_free(iter->pathdata.Points); free(iter->pathdata.Points);
heap_free(iter); free(iter);
return Ok; return Ok;
} }

View file

@ -94,8 +94,8 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if(!pen || !clonepen) if(!pen || !clonepen)
return InvalidParameter; return InvalidParameter;
*clonepen = heap_alloc_zero(sizeof(GpPen)); *clonepen = malloc(sizeof(GpPen));
if(!*clonepen) return OutOfMemory; if(!*clonepen) return OutOfMemory;
**clonepen = *pen; **clonepen = *pen;
@ -115,7 +115,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if (stat == Ok && pen->dashes) if (stat == Ok && pen->dashes)
{ {
(*clonepen)->dashes = heap_alloc_zero(pen->numdashes * sizeof(REAL)); (*clonepen)->dashes = malloc(pen->numdashes * sizeof(REAL));
if ((*clonepen)->dashes) if ((*clonepen)->dashes)
memcpy((*clonepen)->dashes, pen->dashes, pen->numdashes * sizeof(REAL)); memcpy((*clonepen)->dashes, pen->dashes, pen->numdashes * sizeof(REAL));
else else
@ -124,7 +124,7 @@ GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
if (stat == Ok && pen->compound_array) 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) if ((*clonepen)->compound_array)
memcpy((*clonepen)->compound_array, pen->compound_array, pen->compound_array_size * sizeof(REAL)); memcpy((*clonepen)->compound_array, pen->compound_array, pen->compound_array_size * sizeof(REAL));
else else
@ -168,8 +168,8 @@ GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
if(!pen || !brush) if(!pen || !brush)
return InvalidParameter; return InvalidParameter;
gp_pen = heap_alloc_zero(sizeof(GpPen)); gp_pen = calloc(1, sizeof(GpPen));
if(!gp_pen) return OutOfMemory; if(!gp_pen) return OutOfMemory;
gp_pen->style = GP_DEFAULT_PENSTYLE; gp_pen->style = GP_DEFAULT_PENSTYLE;
gp_pen->width = width; 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))) { if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) {
FIXME("UnitWorld, UnitPixel only supported units\n"); FIXME("UnitWorld, UnitPixel only supported units\n");
heap_free(gp_pen); free(gp_pen);
return NotImplemented; return NotImplemented;
} }
@ -210,9 +210,9 @@ GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
GdipDeleteBrush(pen->brush); GdipDeleteBrush(pen->brush);
GdipDeleteCustomLineCap(pen->customstart); GdipDeleteCustomLineCap(pen->customstart);
GdipDeleteCustomLineCap(pen->customend); GdipDeleteCustomLineCap(pen->customend);
heap_free(pen->compound_array); free(pen->compound_array);
heap_free(pen->dashes); free(pen->dashes);
heap_free(pen); free(pen);
return Ok; return Ok;
} }
@ -577,10 +577,10 @@ GpStatus WINGDIPAPI GdipSetPenCompoundArray(GpPen *pen, GDIPCONST REAL *compound
return InvalidParameter; return InvalidParameter;
} }
tmp = heap_alloc_zero(count * sizeof(REAL)); tmp = malloc(count * sizeof(REAL));
if(!tmp) if(!tmp)
return OutOfMemory; return OutOfMemory;
heap_free(pen->compound_array); free(pen->compound_array);
pen->compound_array = tmp; pen->compound_array = tmp;
memcpy(pen->compound_array, compoundarray, count * sizeof(REAL)); memcpy(pen->compound_array, compoundarray, count * sizeof(REAL));
pen->compound_array_size = count; pen->compound_array_size = count;
@ -643,11 +643,11 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
return InvalidParameter; return InvalidParameter;
} }
heap_free(pen->dashes); free(pen->dashes);
pen->dashes = NULL; pen->dashes = NULL;
if(count > 0) if(count > 0)
pen->dashes = heap_alloc_zero(count * sizeof(REAL)); pen->dashes = malloc(count * sizeof(REAL));
if(!pen->dashes){ if(!pen->dashes){
pen->numdashes = 0; pen->numdashes = 0;
return OutOfMemory; return OutOfMemory;
@ -693,7 +693,7 @@ GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
return InvalidParameter; return InvalidParameter;
if(dash != DashStyleCustom){ if(dash != DashStyleCustom){
heap_free(pen->dashes); free(pen->dashes);
pen->dashes = NULL; pen->dashes = NULL;
pen->numdashes = 0; pen->numdashes = 0;
} }

View file

@ -144,7 +144,7 @@ static inline GpStatus clone_element(const region_element* element,
/* root node is allocated with GpRegion */ /* root node is allocated with GpRegion */
if(!*element2){ if(!*element2){
*element2 = heap_alloc_zero(sizeof(region_element)); *element2 = calloc(1, sizeof(region_element));
if (!*element2) if (!*element2)
return OutOfMemory; return OutOfMemory;
} }
@ -217,7 +217,7 @@ GpStatus WINGDIPAPI GdipCloneRegion(GpRegion *region, GpRegion **clone)
if (!(region && clone)) if (!(region && clone))
return InvalidParameter; return InvalidParameter;
*clone = heap_alloc_zero(sizeof(GpRegion)); *clone = calloc(1, sizeof(GpRegion));
if (!*clone) if (!*clone)
return OutOfMemory; return OutOfMemory;
element = &(*clone)->node; element = &(*clone)->node;
@ -248,11 +248,11 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
if(mode == CombineModeReplace){ if(mode == CombineModeReplace){
delete_element(&region->node); delete_element(&region->node);
memcpy(region, path_region, sizeof(GpRegion)); memcpy(region, path_region, sizeof(GpRegion));
heap_free(path_region); free(path_region);
return Ok; return Ok;
} }
left = heap_alloc_zero(sizeof(region_element)); left = malloc(sizeof(region_element));
if (left) if (left)
{ {
*left = region->node; *left = region->node;
@ -267,7 +267,7 @@ GpStatus WINGDIPAPI GdipCombineRegionPath(GpRegion *region, GpPath *path, Combin
else else
stat = OutOfMemory; stat = OutOfMemory;
heap_free(left); free(left);
GdipDeleteRegion(path_region); GdipDeleteRegion(path_region);
return stat; return stat;
} }
@ -295,11 +295,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
if(mode == CombineModeReplace){ if(mode == CombineModeReplace){
delete_element(&region->node); delete_element(&region->node);
memcpy(region, rect_region, sizeof(GpRegion)); memcpy(region, rect_region, sizeof(GpRegion));
heap_free(rect_region); free(rect_region);
return Ok; return Ok;
} }
left = heap_alloc_zero(sizeof(region_element)); left = malloc(sizeof(region_element));
if (left) if (left)
{ {
memcpy(left, &region->node, sizeof(region_element)); memcpy(left, &region->node, sizeof(region_element));
@ -314,7 +314,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRect(GpRegion *region,
else else
stat = OutOfMemory; stat = OutOfMemory;
heap_free(left); free(left);
GdipDeleteRegion(rect_region); GdipDeleteRegion(rect_region);
return stat; return stat;
} }
@ -358,11 +358,11 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
delete_element(&region1->node); delete_element(&region1->node);
memcpy(region1, reg2copy, sizeof(GpRegion)); memcpy(region1, reg2copy, sizeof(GpRegion));
heap_free(reg2copy); free(reg2copy);
return Ok; return Ok;
} }
left = heap_alloc_zero(sizeof(region_element)); left = malloc(sizeof(region_element));
if (!left) if (!left)
return OutOfMemory; return OutOfMemory;
@ -370,7 +370,7 @@ GpStatus WINGDIPAPI GdipCombineRegionRegion(GpRegion *region1,
stat = clone_element(&region2->node, &right); stat = clone_element(&region2->node, &right);
if (stat != Ok) if (stat != Ok)
{ {
heap_free(left); free(left);
return OutOfMemory; return OutOfMemory;
} }
@ -390,7 +390,7 @@ GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
if(!region) if(!region)
return InvalidParameter; return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion)); *region = calloc(1, sizeof(GpRegion));
if(!*region) if(!*region)
return OutOfMemory; return OutOfMemory;
@ -428,7 +428,7 @@ GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
if (!(path && region)) if (!(path && region))
return InvalidParameter; return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion)); *region = calloc(1, sizeof(GpRegion));
if(!*region) if(!*region)
return OutOfMemory; return OutOfMemory;
stat = init_region(*region, RegionDataPath); stat = init_region(*region, RegionDataPath);
@ -462,7 +462,7 @@ GpStatus WINGDIPAPI GdipCreateRegionRect(GDIPCONST GpRectF *rect,
if (!(rect && region)) if (!(rect && region))
return InvalidParameter; return InvalidParameter;
*region = heap_alloc_zero(sizeof(GpRegion)); *region = calloc(1, sizeof(GpRegion));
stat = init_region(*region, RegionDataRect); stat = init_region(*region, RegionDataRect);
if(stat != Ok) if(stat != Ok)
{ {
@ -510,32 +510,32 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
if(!region || !(size = GetRegionData(hrgn, 0, NULL))) if(!region || !(size = GetRegionData(hrgn, 0, NULL)))
return InvalidParameter; return InvalidParameter;
buf = heap_alloc_zero(size); buf = malloc(size);
if(!buf) if(!buf)
return OutOfMemory; return OutOfMemory;
if(!GetRegionData(hrgn, size, buf)){ if(!GetRegionData(hrgn, size, buf)){
heap_free(buf); free(buf);
return GenericError; return GenericError;
} }
if(buf->rdh.nCount == 0){ if(buf->rdh.nCount == 0){
if((stat = GdipCreateRegion(&local)) != Ok){ if((stat = GdipCreateRegion(&local)) != Ok){
heap_free(buf); free(buf);
return stat; return stat;
} }
if((stat = GdipSetEmpty(local)) != Ok){ if((stat = GdipSetEmpty(local)) != Ok){
heap_free(buf); free(buf);
GdipDeleteRegion(local); GdipDeleteRegion(local);
return stat; return stat;
} }
*region = local; *region = local;
heap_free(buf); free(buf);
return Ok; return Ok;
} }
if((stat = GdipCreatePath(FillModeAlternate, &path)) != Ok){ if((stat = GdipCreatePath(FillModeAlternate, &path)) != Ok){
heap_free(buf); free(buf);
return stat; return stat;
} }
@ -543,7 +543,7 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
for(i = 0; i < buf->rdh.nCount; i++){ for(i = 0; i < buf->rdh.nCount; i++){
if((stat = GdipAddPathRectangle(path, (REAL)rect->left, (REAL)rect->top, if((stat = GdipAddPathRectangle(path, (REAL)rect->left, (REAL)rect->top,
(REAL)(rect->right - rect->left), (REAL)(rect->bottom - rect->top))) != Ok){ (REAL)(rect->right - rect->left), (REAL)(rect->bottom - rect->top))) != Ok){
heap_free(buf); free(buf);
GdipDeletePath(path); GdipDeletePath(path);
return stat; return stat;
} }
@ -552,7 +552,7 @@ GpStatus WINGDIPAPI GdipCreateRegionHrgn(HRGN hrgn, GpRegion **region)
stat = GdipCreateRegionPath(path, region); stat = GdipCreateRegionPath(path, region);
heap_free(buf); free(buf);
GdipDeletePath(path); GdipDeletePath(path);
return stat; return stat;
} }
@ -568,7 +568,7 @@ GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
return InvalidParameter; return InvalidParameter;
delete_element(&region->node); delete_element(&region->node);
heap_free(region); free(region);
return Ok; return Ok;
} }
@ -787,12 +787,12 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
{ {
region_element *left, *right; region_element *left, *right;
left = heap_alloc_zero(sizeof(region_element)); left = calloc(1, sizeof(region_element));
if (!left) return OutOfMemory; if (!left) return OutOfMemory;
right = heap_alloc_zero(sizeof(region_element)); right = calloc(1, sizeof(region_element));
if (!right) if (!right)
{ {
heap_free(left); free(left);
return OutOfMemory; return OutOfMemory;
} }
@ -809,8 +809,8 @@ static GpStatus read_element(struct memory_buffer *mbuf, GpRegion *region, regio
} }
} }
heap_free(left); free(left);
heap_free(right); free(right);
return status; return status;
} }
@ -1447,7 +1447,7 @@ static GpStatus transform_region_element(region_element* element, GpMatrix *matr
{ {
/* Steal the element from the created region. */ /* Steal the element from the created region. */
memcpy(element, &new_region->node, sizeof(region_element)); memcpy(element, &new_region->node, sizeof(region_element));
heap_free(new_region); free(new_region);
} }
else else
return stat; return stat;
@ -1553,7 +1553,7 @@ static GpStatus get_region_scans_data(GpRegion *region, GpMatrix *matrix, LPRGND
{ {
data_size = GetRegionData(hrgn, 0, NULL); data_size = GetRegionData(hrgn, 0, NULL);
*data = heap_alloc_zero(data_size); *data = malloc(data_size);
if (*data) if (*data)
GetRegionData(hrgn, data_size, *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_size = sizeof(RGNDATAHEADER) + sizeof(RECT);
*data = heap_alloc_zero(data_size); *data = calloc(1, data_size);
if (*data) if (*data)
{ {
@ -1605,7 +1605,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansCount(GpRegion *region, UINT *count, GpMat
if (stat == Ok) if (stat == Ok)
{ {
*count = data->rdh.nCount; *count = data->rdh.nCount;
heap_free(data); free(data);
} }
return stat; return stat;
@ -1639,7 +1639,7 @@ GpStatus WINGDIPAPI GdipGetRegionScansI(GpRegion *region, GpRect *scans, INT *co
} }
} }
heap_free(data); free(data);
} }
return Ok; return Ok;
@ -1673,7 +1673,7 @@ GpStatus WINGDIPAPI GdipGetRegionScans(GpRegion *region, GpRectF *scans, INT *co
} }
} }
heap_free(data); free(data);
} }
return Ok; return Ok;

View file

@ -66,11 +66,11 @@ void init_generic_string_formats(void)
void free_generic_string_formats(void) void free_generic_string_formats(void)
{ {
heap_free(generic_default_format.character_ranges); free(generic_default_format.character_ranges);
heap_free(generic_default_format.tabs); free(generic_default_format.tabs);
heap_free(generic_typographic_format.character_ranges); free(generic_typographic_format.character_ranges);
heap_free(generic_typographic_format.tabs); free(generic_typographic_format.tabs);
} }
GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang, GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
@ -81,8 +81,8 @@ GpStatus WINGDIPAPI GdipCreateStringFormat(INT attr, LANGID lang,
if(!format) if(!format)
return InvalidParameter; return InvalidParameter;
*format = heap_alloc_zero(sizeof(GpStringFormat)); *format = calloc(1, sizeof(GpStringFormat));
if(!*format) return OutOfMemory; if(!*format) return OutOfMemory;
(*format)->attr = attr; (*format)->attr = attr;
(*format)->lang = lang; (*format)->lang = lang;
@ -110,9 +110,9 @@ GpStatus WINGDIPAPI GdipDeleteStringFormat(GpStringFormat *format)
if (format == &generic_default_format || format == &generic_typographic_format) if (format == &generic_default_format || format == &generic_typographic_format)
return Ok; return Ok;
heap_free(format->character_ranges); free(format->character_ranges);
heap_free(format->tabs); free(format->tabs);
heap_free(format); free(format);
return Ok; return Ok;
} }
@ -297,11 +297,11 @@ GpStatus WINGDIPAPI GdipSetStringFormatMeasurableCharacterRanges(
TRACE("%p, %d, %p\n", format, rangeCount, ranges); 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) if (!new_ranges)
return OutOfMemory; return OutOfMemory;
heap_free(format->character_ranges); free(format->character_ranges);
format->character_ranges = new_ranges; format->character_ranges = new_ranges;
memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount); memcpy(format->character_ranges, ranges, sizeof(CharacterRange) * rangeCount);
format->range_count = rangeCount; format->range_count = rangeCount;
@ -319,16 +319,9 @@ GpStatus WINGDIPAPI GdipSetStringFormatTabStops(GpStringFormat *format, REAL fir
if(count > 0){ if(count > 0){
if(firsttab < 0.0) return NotImplemented; if(firsttab < 0.0) return NotImplemented;
/* first time allocation */ if(format->tabcount < count){
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)){
REAL *ptr; REAL *ptr;
ptr = heap_realloc(format->tabs, sizeof(REAL)*count); ptr = realloc(format->tabs, sizeof(REAL) * count);
if(!ptr) if(!ptr)
return OutOfMemory; return OutOfMemory;
format->tabs = ptr; format->tabs = ptr;
@ -371,15 +364,15 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
if(!format || !newFormat) if(!format || !newFormat)
return InvalidParameter; return InvalidParameter;
*newFormat = heap_alloc_zero(sizeof(GpStringFormat)); *newFormat = malloc(sizeof(GpStringFormat));
if(!*newFormat) return OutOfMemory; if(!*newFormat) return OutOfMemory;
**newFormat = *format; **newFormat = *format;
if(format->tabcount > 0){ if(format->tabcount > 0){
(*newFormat)->tabs = heap_alloc_zero(sizeof(REAL) * format->tabcount); (*newFormat)->tabs = malloc(sizeof(REAL) * format->tabcount);
if(!(*newFormat)->tabs){ if(!(*newFormat)->tabs){
heap_free(*newFormat); free(*newFormat);
return OutOfMemory; return OutOfMemory;
} }
memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount); memcpy((*newFormat)->tabs, format->tabs, sizeof(REAL) * format->tabcount);
@ -388,10 +381,10 @@ GpStatus WINGDIPAPI GdipCloneStringFormat(GDIPCONST GpStringFormat *format, GpSt
(*newFormat)->tabs = NULL; (*newFormat)->tabs = NULL;
if(format->range_count > 0){ 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){ if(!(*newFormat)->character_ranges){
heap_free((*newFormat)->tabs); free((*newFormat)->tabs);
heap_free(*newFormat); free(*newFormat);
return OutOfMemory; return OutOfMemory;
} }
memcpy((*newFormat)->character_ranges, format->character_ranges, memcpy((*newFormat)->character_ranges, format->character_ranges,