From: Mark Cave-Ayland Date: Thu, 19 Nov 2009 15:15:55 +0000 (+0000) Subject: Apply a slightly modified version of Dave Fuhry's patch for a memory leak in shp2pgsq... X-Git-Tag: 1.4.1rc2~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e76c3e13b5be1f1b1d1bb1fc7570db8ccb2ee269;p=postgis Apply a slightly modified version of Dave Fuhry's patch for a memory leak in shp2pgsql. Thanks Dave! git-svn-id: http://svn.osgeo.org/postgis/branches/1.4@4861 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql.c b/loader/shp2pgsql.c index 49007a8d9..f834215d3 100644 --- a/loader/shp2pgsql.c +++ b/loader/shp2pgsql.c @@ -461,6 +461,7 @@ main (int ARGC, char **ARGV) printf("END;\n"); /* End the last transaction */ + Cleanup(); return 0; }/*end main() */ @@ -1173,8 +1174,6 @@ InsertPolygon(void) lwpolygons[pi] = lwpoly_as_lwgeom(lwpoly); } - ReleasePolygons(Outer, polygon_total); - /* If using MULTIPOLYGONS then generate the serialized collection, otherwise just a single POLYGON */ if (simple_geometries == 0) { @@ -1186,6 +1185,22 @@ InsertPolygon(void) serialized_lwgeom = lwgeom_serialize(lwpolygons[0]); } + for(pi = 0; pi < polygon_total; pi++) + { + Ring *polyring = Outer[pi]; + int ring_index = 0; + while (polyring) + { + lwfree(pas[pi][ring_index]->serialized_pointlist); + lwfree(pas[pi][ring_index]); + + polyring = polyring->next; + ring_index++; + } + } + + ReleasePolygons(Outer, polygon_total); + if (!hwgeom) result = serialized_lwgeom_to_hexwkb(&lwg_unparser_result, serialized_lwgeom, PARSER_CHECK_NONE, -1); else