]> granicus.if.org Git - postgis/commitdiff
reduced memory copies in GEOS2POSTGIS()
authorSandro Santilli <strk@keybit.net>
Tue, 21 Sep 2004 16:08:03 +0000 (16:08 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 21 Sep 2004 16:08:03 +0000 (16:08 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@864 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_geos.c

index c2b7d4d2bbc123cfe8e4d3ada94cfc280ed4836c..7bfc8f74d90124c1dec016111625ad1f95b906ce 100644 (file)
@@ -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;
 }