From: David Kahurani k.kahurani@gmail.com
This re-implementation removed unnecessary API call to GdipGetPathPoints and avoids allocating memory unnecessarily. Ontop of that, it is quite likely that this API doesn't ever return OutOfMemory errors.
Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/gdiplus/graphicspath.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 24c2888cfe8..050ff46ef6b 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -1501,8 +1501,6 @@ GpStatus WINGDIPAPI GdipGetPathPoints(GpPath *path, GpPointF* points, INT count)
GpStatus WINGDIPAPI GdipGetPathPointsI(GpPath *path, GpPoint* points, INT count) { - GpStatus ret; - GpPointF *ptf; INT i;
TRACE("(%p, %p, %d)\n", path, points, count); @@ -1510,18 +1508,15 @@ GpStatus WINGDIPAPI GdipGetPathPointsI(GpPath *path, GpPoint* points, INT count) if(count <= 0) return InvalidParameter;
- ptf = malloc(sizeof(GpPointF) * count); - if(!ptf) return OutOfMemory; - - ret = GdipGetPathPoints(path,ptf,count); - if(ret == Ok) - for(i = 0;i < count;i++){ - points[i].X = gdip_round(ptf[i].X); - points[i].Y = gdip_round(ptf[i].Y); - }; - free(ptf); + if(count < path->pathdata.Count) + return InsufficientBuffer; + + for(i = 0;i < path->pathdata.Count ;i++){ + points[i].X = gdip_round(path->pathdata.Points[i].X); + points[i].Y = gdip_round(path->pathdata.Points[i].Y); + };
- return ret; + return Ok; }
GpStatus WINGDIPAPI GdipGetPathTypes(GpPath *path, BYTE* types, INT count)