[geos-commits] r2371 - in trunk/source: headers/geos/index/quadtree
index/quadtree
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Apr 15 07:17:29 EDT 2009
Author: strk
Date: 2009-04-15 07:17:29 -0400 (Wed, 15 Apr 2009)
New Revision: 2371
Modified:
trunk/source/headers/geos/index/quadtree/Key.h
trunk/source/headers/geos/index/quadtree/Node.h
trunk/source/index/quadtree/Key.cpp
Log:
Few more docs about memory management in quadtree indexing; fix a potential leak in quadtree::Key
Modified: trunk/source/headers/geos/index/quadtree/Key.h
===================================================================
--- trunk/source/headers/geos/index/quadtree/Key.h 2009-04-15 10:43:48 UTC (rev 2370)
+++ trunk/source/headers/geos/index/quadtree/Key.h 2009-04-15 11:17:29 UTC (rev 2371)
@@ -37,20 +37,37 @@
*/
class Key {
public:
+
+ // Doesn't touch the Envelope, might as well be const
static int computeQuadLevel(geom::Envelope *env);
+
Key(geom::Envelope *itemEnv);
virtual ~Key();
+
+ /// Returned object ownership retained by this class
geom::Coordinate* getPoint();
+
int getLevel();
+
+ /// Returned object ownership retained by this class
geom::Envelope* getEnvelope();
+
+ /// Returns newly allocated object (ownership transferred)
geom::Coordinate* getCentre();
+
void computeKey(geom::Envelope *itemEnv);
private:
// the fields which make up the key
+
+ // Owned by this class
geom::Coordinate *pt;
+
int level;
+
// auxiliary data which is derived from the key for use in computation
+ // Owned by this class
geom::Envelope *env;
+
void computeKey(int level,geom::Envelope *itemEnv);
};
Modified: trunk/source/headers/geos/index/quadtree/Node.h
===================================================================
--- trunk/source/headers/geos/index/quadtree/Node.h 2009-04-15 10:43:48 UTC (rev 2370)
+++ trunk/source/headers/geos/index/quadtree/Node.h 2009-04-15 11:17:29 UTC (rev 2371)
@@ -46,6 +46,7 @@
private:
+ /// Owned by this class
geom::Envelope *env;
geom::Coordinate centre;
@@ -81,6 +82,8 @@
virtual ~Node() { delete env; }
+ /// Return Envelope associated with this node
+ /// ownership retained by this object
geom::Envelope* getEnvelope() { return env; }
/** \brief
Modified: trunk/source/index/quadtree/Key.cpp
===================================================================
--- trunk/source/index/quadtree/Key.cpp 2009-04-15 10:43:48 UTC (rev 2370)
+++ trunk/source/index/quadtree/Key.cpp 2009-04-15 11:17:29 UTC (rev 2371)
@@ -84,7 +84,8 @@
*/
void Key::computeKey(Envelope *itemEnv) {
level=computeQuadLevel(itemEnv);
- env=new Envelope();
+ delete env;
+ env=new Envelope();
computeKey(level,itemEnv);
// MD - would be nice to have a non-iterative form of this algorithm
while (!env->contains(itemEnv)) {
More information about the geos-commits
mailing list