[2/6] gdiplus: Avoid not necessary memory allocations in GdipCreateRegionPath.

Dmitry Timoshkov dmitry at baikal.ru
Fri Nov 8 01:33:31 CST 2013


---
 dlls/gdiplus/region.c | 41 +++++------------------------------------
 1 file 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);
-- 
1.8.4.1




More information about the wine-patches mailing list