]> granicus.if.org Git - postgis/commitdiff
Reduce p-i-p memory leak by 50%
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 23 Sep 2008 19:07:03 +0000 (19:07 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 23 Sep 2008 19:07:03 +0000 (19:07 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2993 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_rtree.c

index e967b92150c02373285217f3c0af3c176f31d585..81bf1afe61a0f7461ab4b4656c0e178b01dba5e6 100644 (file)
@@ -422,7 +422,11 @@ RTREE_POLY_CACHE *retrieveCache(LWPOLY *poly, uchar *serializedPoly,
         if(lwgeom_size_poly(currentCache->poly) != length)
         {
                 LWDEBUG(3, "Polygon size mismatch, creating new cache.");
-
+                for(i = 0; i < currentCache->ringCount; i++)
+                {
+                       freeTree(currentCache->ringIndices[i]);
+                }
+                lwfree(currentCache->ringIndices);
                 lwfree(currentCache->poly);
                 lwfree(currentCache);
                 return createNewCache(poly, serializedPoly);
@@ -435,6 +439,11 @@ RTREE_POLY_CACHE *retrieveCache(LWPOLY *poly, uchar *serializedPoly,
                 {
                         LWDEBUGF(3, "Polygon mismatch, creating new cache. %c, %c", a, b);
 
+                        for(i = 0; i < currentCache->ringCount; i++)
+                        { 
+                               freeTree(currentCache->ringIndices[i]);
+                        }
+                        lwfree(currentCache->ringIndices);
                         lwfree(currentCache->poly);
                         lwfree(currentCache);
                         return createNewCache(poly, serializedPoly);