gdiplus: fix for GdipGetPathData. Commited version was wrong.

Nikolay Sivov bunglehead at gmail.com
Wed Jun 25 12:56:27 CDT 2008


Changelog:
    Fix GdipGetPathData implementation and test. 
    Previous version (commit 3bacdaf664593b720afeb55a94225aab5aa04c80) was totally incorrect.
    Thanks Paul Vriens to point on that.

    - Allocation/freeing of GpPathData data controlled by wrapper.
    - Test correct as well.

---
 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);
-- 
1.4.4.4






More information about the wine-patches mailing list