Dmitry Timoshkov : gdiplus: Avoid not necessary memory allocations in GdipCreateRegionPath.

Alexandre Julliard julliard at winehq.org
Fri Nov 8 10:36:49 CST 2013


Module: wine
Branch: master
Commit: 394d4b07e65635fed76779c495f94ba90369a6c8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=394d4b07e65635fed76779c495f94ba90369a6c8

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Nov  8 16:33:31 2013 +0900

gdiplus: Avoid not necessary memory allocations in GdipCreateRegionPath.

---

 dlls/gdiplus/region.c |   41 +++++------------------------------------
 1 files changed, 5 insertions(+), 36 deletions(-)

diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c
index 3e718ef..9ac3124 100644
--- a/dlls/gdiplus/region.c
+++ b/dlls/gdiplus/region.c
@@ -425,9 +425,6 @@ GpStatus WINGDIPAPI GdipCreateRegion(GpRegion **region)
 GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
 {
     region_element* element;
-    GpPoint  *pointsi;
-    GpPointF *pointsf;
-
     GpStatus stat;
     DWORD flags = FLAGS_INTPATH;
     INT count, i;
@@ -450,42 +447,14 @@ GpStatus WINGDIPAPI GdipCreateRegionPath(GpPath *path, GpRegion **region)
     count = path->pathdata.Count;
 
     /* Test to see if the path is an Integer path */
-    if (count)
+    for (i = 0; i < count; i++)
     {
-        pointsi = GdipAlloc(sizeof(GpPoint) * count);
-        pointsf = GdipAlloc(sizeof(GpPointF) * count);
-        if (!(pointsi && pointsf))
+        if (path->pathdata.Points[i].X != gdip_round(path->pathdata.Points[i].X) ||
+            path->pathdata.Points[i].Y != gdip_round(path->pathdata.Points[i].Y))
         {
-            GdipFree(pointsi);
-            GdipFree(pointsf);
-            GdipDeleteRegion(*region);
-            return OutOfMemory;
-        }
-
-        stat = GdipGetPathPointsI(path, pointsi, count);
-        if (stat != Ok)
-        {
-            GdipDeleteRegion(*region);
-            return stat;
-        }
-        stat = GdipGetPathPoints(path, pointsf, count);
-        if (stat != Ok)
-        {
-            GdipDeleteRegion(*region);
-            return stat;
-        }
-
-        for (i = 0; i < count; i++)
-        {
-            if (!(pointsi[i].X == pointsf[i].X &&
-                  pointsi[i].Y == pointsf[i].Y ))
-            {
-                flags = FLAGS_NOFLAGS;
-                break;
-            }
+            flags = FLAGS_NOFLAGS;
+            break;
         }
-        GdipFree(pointsi);
-        GdipFree(pointsf);
     }
 
     stat = GdipClonePath(path, &element->elementdata.pathdata.path);




More information about the wine-cvs mailing list