From: Sandro Santilli Date: Tue, 21 Sep 2004 16:08:03 +0000 (+0000) Subject: reduced memory copies in GEOS2POSTGIS() X-Git-Tag: pgis_1_0_0RC1~408 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c1c4b5b2c4dd11374a6de2acdbd91235a3e1758;p=postgis reduced memory copies in GEOS2POSTGIS() git-svn-id: http://svn.osgeo.org/postgis/trunk@864 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/lwgeom/lwgeom_geos.c b/lwgeom/lwgeom_geos.c index c2b7d4d2b..7bfc8f74d 100644 --- a/lwgeom/lwgeom_geos.c +++ b/lwgeom/lwgeom_geos.c @@ -1454,6 +1454,7 @@ GEOS2POSTGIS(Geometry *geom, char want3d) LWGEOM_EXPLODED *oexp; int SRID = GEOSGetSRID(geom); int wantbbox = 0; // might as well be 1 ... + int size; // Initialize exploded lwgeom oexp = (LWGEOM_EXPLODED *)palloc(sizeof(LWGEOM_EXPLODED)); @@ -1466,10 +1467,14 @@ GEOS2POSTGIS(Geometry *geom, char want3d) oexp->npolys = 0; oexp->polys = palloc(sizeof(char *)); - addToExploded_recursive(geom, oexp); - serialized = lwexploded_serialize(oexp, wantbbox); - result = LWGEOM_construct(serialized, SRID, wantbbox); + + size = lwexploded_findlength(oexp, wantbbox); + size += 4; // postgresql size header + result = palloc(size); + result->size = size; + lwexploded_serialize_buf(oexp, wantbbox, SERIALIZED_FORM(result), NULL); + return result; }