Module: wine Branch: master Commit: 991e785f507c13d6ebe648e650ff1ae3346ca2cd URL: http://source.winehq.org/git/wine.git/?a=commit;h=991e785f507c13d6ebe648e650...
Author: Nikolay Sivov bunglehead@gmail.com Date: Wed Jun 25 21:56:27 2008 +0400
gdiplus: Fix GdipGetPathData implementation and test.
Previous version (commit 3bacdaf664593b720afeb55a94225aab5aa04c80) was totally incorrect. Thanks to Paul Vriens for pointing this out.
---
dlls/gdiplus/graphicspath.c | 13 ++----------- dlls/gdiplus/tests/graphicspath.c | 10 +++++++++- 2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/dlls/gdiplus/graphicspath.c b/dlls/gdiplus/graphicspath.c index 24f25e1..d17b392 100644 --- a/dlls/gdiplus/graphicspath.c +++ b/dlls/gdiplus/graphicspath.c @@ -484,17 +484,8 @@ GpStatus WINGDIPAPI GdipGetPathData(GpPath *path, GpPathData* pathData) if(!path || !pathData) return InvalidParameter;
- pathData->Count = path->pathdata.Count; - - pathData->Points = GdipAlloc(sizeof(PointF) * pathData->Count); - if(!pathData->Points) - return OutOfMemory; - - pathData->Types = GdipAlloc(pathData->Count); - if(!pathData->Points) - return OutOfMemory; - - /* copy data */ + /* Only copy data. pathData allocation/freeing controlled by wrapper class. + Assumed that pathData is enough wide to get all data - controlled by wrapper too. */ memcpy(pathData->Points, path->pathdata.Points, sizeof(PointF) * pathData->Count); memcpy(pathData->Types , path->pathdata.Types , pathData->Count);
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c index 672f6da..262a527 100644 --- a/dlls/gdiplus/tests/graphicspath.c +++ b/dlls/gdiplus/tests/graphicspath.c @@ -154,14 +154,22 @@ static void test_getpathdata(void) GpPath *path; GpPathData data; GpStatus status; + INT count;
GdipCreatePath(FillModeAlternate, &path); status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0); expect(Ok, status);
+ /* Prepare storage. Made by wrapper class. */ + status = GdipGetPointCount(path, &count); + expect(Ok, status); + + data.Count = 2; + data.Types = GdipAlloc(sizeof(BYTE) * count); + data.Points = GdipAlloc(sizeof(PointF) * count); + status = GdipGetPathData(path, &data); expect(Ok, status); - expect((data.Count == 2), TRUE); expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) && (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE); expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE);