Commit ef6ca1b8 authored by Paul Ramsey's avatar Paul Ramsey

Add in lwfree_* deep memory clean-up routines for multi-objects.


git-svn-id: http://svn.osgeo.org/postgis/[email protected] b70326c6-7e19-0410-871a-916f4a2858ee
parent 2e18dbbb
......@@ -948,7 +948,10 @@ extern void lwfree_point (LWPOINT *pt);
extern void lwfree_line (LWLINE *line);
extern void lwfree_polygon (LWPOLY *poly);
extern void lwfree_pointarray(POINTARRAY *pa);
extern void lwfree_mpoint (LWMPOINT *mpt);
extern void lwfree_mline (LWMLINE *mline);
extern void lwfree_mpolygon (LWMPOLY *mpoly);
extern void lwfree_collection (LWCOLLECTION *col);
/****************************************************************
* utility
......
......@@ -354,3 +354,48 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
}
return 1;
}
void lwfree_collection(LWCOLLECTION *col)
{
int i;
if( col->bbox )
{
lwfree(col->bbox);
}
for ( i = 0; i < col->ngeoms; i++ )
{
if( col->geoms[i] ) {
switch( TYPE_GETTYPE(col->geoms[i]->type) )
{
case POINTTYPE:
lwfree_point((LWPOINT*)col->geoms[i]);
break;
case LINETYPE:
lwfree_line((LWLINE*)col->geoms[i]);
break;
case POLYGONTYPE:
lwfree_polygon((LWPOLY*)col->geoms[i]);
break;
case MULTIPOINTTYPE:
lwfree_mpoint((LWMPOINT*)col->geoms[i]);
break;
case MULTILINETYPE:
lwfree_mline((LWMLINE*)col->geoms[i]);
break;
case MULTIPOLYGONTYPE:
lwfree_mpolygon((LWMPOLY*)col->geoms[i]);
break;
case COLLECTIONTYPE:
lwfree_collection((LWCOLLECTION*)col->geoms[i]);
break;
}
}
}
if( col->geoms )
{
lwfree(col->geoms);
}
lwfree(col);
};
\ No newline at end of file
......@@ -108,3 +108,24 @@ lwmline_add(const LWMLINE *to, uint32 where, const LWGEOM *what)
return (LWGEOM *)col;
}
void lwfree_mline(LWMLINE *mline)
{
int i;
if( mline->bbox )
{
lwfree(mline->bbox);
}
for ( i = 0; i < mline->ngeoms; i++ )
{
if( mline->geoms[i] ) {
lwfree_line(mline->geoms[i]);
}
}
if( mline->geoms )
{
lwfree(mline->geoms);
}
lwfree(mline);
};
......@@ -107,3 +107,24 @@ lwmpoint_add(const LWMPOINT *to, uint32 where, const LWGEOM *what)
return (LWGEOM *)col;
}
void lwfree_mpoint(LWMPOINT *mpt)
{
int i;
if( mpt->bbox )
{
lwfree(mpt->bbox);
}
for ( i = 0; i < mpt->ngeoms; i++ )
{
if( mpt->geoms[i] ) {
lwfree_point(mpt->geoms[i]);
}
}
if( mpt->geoms )
{
lwfree(mpt->geoms);
}
lwfree(mpt);
};
\ No newline at end of file
......@@ -110,3 +110,24 @@ lwmpoly_add(const LWMPOLY *to, uint32 where, const LWGEOM *what)
return (LWGEOM *)col;
}
void lwfree_mpolygon(LWMPOLY *mpoly)
{
int i;
if( mpoly->bbox )
{
lwfree(mpoly->bbox);
}
for ( i = 0; i < mpoly->ngeoms; i++ )
{
if( mpoly->geoms[i] ) {
lwfree_polygon(mpoly->geoms[i]);
}
}
if( mpoly->geoms )
{
lwfree(mpoly->geoms);
}
lwfree(mpoly);
};
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment