From: Sandro Santilli Date: Wed, 6 Jul 2011 09:40:38 +0000 (+0000) Subject: Rename ptarray_clone to ptarray_clone_deep, to be conformant with lwgeom_clone_deep... X-Git-Tag: 2.0.0alpha1~1237 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d33f3e4c46b466d5837ead493ab5f3e6be799ed6;p=postgis Rename ptarray_clone to ptarray_clone_deep, to be conformant with lwgeom_clone_deep in that it copies the serialized pointlist too git-svn-id: http://svn.osgeo.org/postgis/trunk@7605 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/liblwgeom.h b/liblwgeom/liblwgeom.h index 253854a43..374e25dd1 100644 --- a/liblwgeom/liblwgeom.h +++ b/liblwgeom/liblwgeom.h @@ -1688,7 +1688,7 @@ LWTRIANGLE *lwtriangle_clone(const LWTRIANGLE *lwgeom); LWCOLLECTION *lwcollection_clone(const LWCOLLECTION *lwgeom); LWCIRCSTRING *lwcircstring_clone(const LWCIRCSTRING *curve); BOX2DFLOAT4 *box2d_clone(const BOX2DFLOAT4 *lwgeom); -POINTARRAY *ptarray_clone(const POINTARRAY *ptarray); +POINTARRAY *ptarray_clone_deep(const POINTARRAY *ptarray); LWLINE *lwline_clone_deep(const LWLINE *lwgeom); LWPOLY *lwpoly_clone_deep(const LWPOLY *lwgeom); LWCOLLECTION *lwcollection_clone_deep(const LWCOLLECTION *lwgeom); diff --git a/liblwgeom/libtgeom.c b/liblwgeom/libtgeom.c index 3acb5fa93..0f33f4549 100644 --- a/liblwgeom/libtgeom.c +++ b/liblwgeom/libtgeom.c @@ -272,7 +272,7 @@ tgeom_add_polygon(TGEOM *tgeom, LWPOLY *poly) /* clone internal rings */ for (i=0 ; i < tgeom->faces[tgeom->nfaces]->nrings ; i++) tgeom->faces[tgeom->nfaces]->rings[i] - = ptarray_clone(poly->rings[i+1]); + = ptarray_clone_deep(poly->rings[i+1]); tgeom->nfaces++; diff --git a/liblwgeom/lwline.c b/liblwgeom/lwline.c index e6dc2b2fa..4bc70dfc3 100644 --- a/liblwgeom/lwline.c +++ b/liblwgeom/lwline.c @@ -353,7 +353,7 @@ lwline_clone_deep(const LWLINE *g) memcpy(ret, g, sizeof(LWLINE)); if ( g->bbox ) ret->bbox = gbox_copy(g->bbox); - if ( g->points ) ret->points = ptarray_clone(g->points); + if ( g->points ) ret->points = ptarray_clone_deep(g->points); FLAGS_SET_READONLY(ret->flags,0); return ret; diff --git a/liblwgeom/lwpoly.c b/liblwgeom/lwpoly.c index be6063ab0..abaebdbb4 100644 --- a/liblwgeom/lwpoly.c +++ b/liblwgeom/lwpoly.c @@ -469,7 +469,7 @@ lwpoly_clone_deep(const LWPOLY *g) ret->rings = lwalloc(sizeof(POINTARRAY *)*g->nrings); for ( i = 0; i < ret->nrings; i++ ) { - ret->rings[i] = ptarray_clone(g->rings[i]); + ret->rings[i] = ptarray_clone_deep(g->rings[i]); } FLAGS_SET_READONLY(ret->flags,0); return ret; @@ -586,7 +586,7 @@ lwpoly_from_lwlines(const LWLINE *shell, lwerror("lwpoly_from_lwlines: shell must have at least 4 points"); if ( ! ptarray_isclosed2d(shell->points) ) lwerror("lwpoly_from_lwlines: shell must be closed"); - rings[0] = ptarray_clone(shell->points); + rings[0] = ptarray_clone_deep(shell->points); for (nrings=1; nrings<=nholes; nrings++) { @@ -600,7 +600,7 @@ lwpoly_from_lwlines(const LWLINE *shell, if ( ! ptarray_isclosed2d(hole->points) ) lwerror("lwpoly_from_lwlines: holes must be closed"); - rings[nrings] = ptarray_clone(hole->points); + rings[nrings] = ptarray_clone_deep(hole->points); } ret = lwpoly_construct(srid, NULL, nrings, rings); diff --git a/liblwgeom/lwsegmentize.c b/liblwgeom/lwsegmentize.c index 9592e5b48..913425d35 100644 --- a/liblwgeom/lwsegmentize.c +++ b/liblwgeom/lwsegmentize.c @@ -356,18 +356,18 @@ lwcurvepoly_segmentize(const LWCURVEPOLY *curvepoly, uint32 perQuad) if (tmp->type == CIRCSTRINGTYPE) { line = lwcircstring_segmentize((LWCIRCSTRING *)tmp, perQuad); - ptarray[i] = ptarray_clone(line->points); + ptarray[i] = ptarray_clone_deep(line->points); lwfree(line); } else if (tmp->type == LINETYPE) { line = (LWLINE *)tmp; - ptarray[i] = ptarray_clone(line->points); + ptarray[i] = ptarray_clone_deep(line->points); } else if (tmp->type == COMPOUNDTYPE) { line = lwcompound_segmentize((LWCOMPOUND *)tmp, perQuad); - ptarray[i] = ptarray_clone(line->points); + ptarray[i] = ptarray_clone_deep(line->points); lwfree(line); } else @@ -402,7 +402,7 @@ lwmcurve_segmentize(LWMCURVE *mcurve, uint32 perQuad) } else if (tmp->type == LINETYPE) { - lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone(((LWLINE *)tmp)->points)); + lines[i] = (LWGEOM *)lwline_construct(mcurve->srid, NULL, ptarray_clone_deep(((LWLINE *)tmp)->points)); } else { @@ -442,7 +442,7 @@ lwmsurface_segmentize(LWMSURFACE *msurface, uint32 perQuad) ptarray = lwalloc(sizeof(POINTARRAY *)*poly->nrings); for (j = 0; j < poly->nrings; j++) { - ptarray[j] = ptarray_clone(poly->rings[j]); + ptarray[j] = ptarray_clone_deep(poly->rings[j]); } polys[i] = (LWGEOM *)lwpoly_construct(msurface->srid, NULL, poly->nrings, ptarray); } diff --git a/liblwgeom/lwtriangle.c b/liblwgeom/lwtriangle.c index 0593fae78..6e48dc358 100644 --- a/liblwgeom/lwtriangle.c +++ b/liblwgeom/lwtriangle.c @@ -396,7 +396,7 @@ lwtriangle_from_lwline(const LWLINE *shell) (FLAGS_GET_Z(shell->flags) && !ptarray_isclosed3d(shell->points)) ) lwerror("lwtriangle_from_lwline: shell must be closed"); - pa = ptarray_clone(shell->points); + pa = ptarray_clone_deep(shell->points); ret = lwtriangle_construct(shell->srid, NULL, pa); if (lwtriangle_is_repeated_points(ret)) diff --git a/liblwgeom/ptarray.c b/liblwgeom/ptarray.c index f878d173b..c6df1e3dc 100644 --- a/liblwgeom/ptarray.c +++ b/liblwgeom/ptarray.c @@ -615,12 +615,12 @@ ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2) * @brief Clone a pointarray */ POINTARRAY * -ptarray_clone(const POINTARRAY *in) +ptarray_clone_deep(const POINTARRAY *in) { POINTARRAY *out = lwalloc(sizeof(POINTARRAY)); size_t size; - LWDEBUG(3, "ptarray_clone called."); + LWDEBUG(3, "ptarray_clone_deep called."); out->flags = in->flags; out->npoints = in->npoints; @@ -1122,7 +1122,7 @@ ptarray_remove_repeated_points(POINTARRAY *in) LWDEBUG(3, "ptarray_remove_repeated_points called."); /* Single or zero point arrays can't have duplicates */ - if ( in->npoints < 3 ) return ptarray_clone(in); + if ( in->npoints < 3 ) return ptarray_clone_deep(in); ptsize = ptarray_point_size(in); diff --git a/postgis/lwgeom_dump.c b/postgis/lwgeom_dump.c index f047135b9..201484f9a 100644 --- a/postgis/lwgeom_dump.c +++ b/postgis/lwgeom_dump.c @@ -274,7 +274,7 @@ Datum LWGEOM_dump_rings(PG_FUNCTION_ARGS) oldcontext = MemoryContextSwitchTo(newcontext); /* We need a copy of input ring here */ - ring = ptarray_clone(poly->rings[state->ringnum]); + ring = ptarray_clone_deep(poly->rings[state->ringnum]); /* Construct another polygon with shell only */ ringgeom = (LWGEOM*)lwpoly_construct( diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 796389bf8..23a9a2cee 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -1818,7 +1818,7 @@ Datum LWGEOM_segmentize2d(PG_FUNCTION_ARGS) outgeom = pglwgeom_serialize(outlwgeom); - //lwgeom_free(outlwgeom); /* TODO fix lwgeom_clone / ptarray_clone for consistent semantics */ + //lwgeom_free(outlwgeom); /* TODO fix lwgeom_clone / ptarray_clone_deep for consistent semantics */ lwgeom_free(inlwgeom); PG_FREE_IF_COPY(ingeom, 0); diff --git a/postgis/lwgeom_in_gml.c b/postgis/lwgeom_in_gml.c index 4a629d73e..ae2494422 100644 --- a/postgis/lwgeom_in_gml.c +++ b/postgis/lwgeom_in_gml.c @@ -652,7 +652,7 @@ static POINTARRAY* parse_gml_coordinates(xmlNodePtr xnode, bool *hasz) /* TODO: this makes no sense, we shouldn't have to clone. but we're seeing memory problems when we don't. */ - return ptarray_clone(dpa); + return ptarray_clone_deep(dpa); } @@ -708,7 +708,7 @@ static POINTARRAY* parse_gml_coord(xmlNodePtr xnode, bool *hasz) ptarray_append_point(dpa, &p, REPEATED_POINTS_NOT_OK); x = y = z = false; - return ptarray_clone(dpa); + return ptarray_clone_deep(dpa); } @@ -784,7 +784,7 @@ static POINTARRAY* parse_gml_pos(xmlNodePtr xnode, bool *hasz) ptarray_append_point(dpa, &pt, REPEATED_POINTS_NOT_OK); } - return ptarray_clone(dpa); + return ptarray_clone_deep(dpa); } @@ -851,7 +851,7 @@ static POINTARRAY* parse_gml_poslist(xmlNodePtr xnode, bool *hasz) xmlFree(gmlposlist); - return ptarray_clone(dpa); + return ptarray_clone_deep(dpa); } diff --git a/postgis/lwgeom_in_kml.c b/postgis/lwgeom_in_kml.c index 5952c4f7c..07c52a5f8 100644 --- a/postgis/lwgeom_in_kml.c +++ b/postgis/lwgeom_in_kml.c @@ -333,7 +333,7 @@ static POINTARRAY* parse_kml_coordinates(xmlNodePtr xnode, bool *hasz) xmlFree(kml_coord); /* TODO: we shouldn't need to clone here */ - return ptarray_clone(dpa); + return ptarray_clone_deep(dpa); }