]> rtime.felk.cvut.cz Git - hubacji1/iamcar.git/commitdiff
Move mem free to RRTBase destructor
authorJiri Hubacek <hubacji1@fel.cvut.cz>
Mon, 17 Sep 2018 07:07:24 +0000 (09:07 +0200)
committerJiri Hubacek <hubacji1@fel.cvut.cz>
Mon, 17 Sep 2018 07:12:07 +0000 (09:12 +0200)
base/main.cc
base/rrtbase.cc
incl/rrtbase.h

index a4522860664c5ed3619e8391389243f2363a4f0f..c17f4f643550d94f2220b61da39b85573574c76d 100644 (file)
@@ -152,13 +152,5 @@ int main()
                 delete o.init();
                 delete o.goal();
         }
-        for (auto n: p.nodes())
-                if (n != p.root())
-                        delete n;
-        for (auto s: p.samples())
-                if (s != p.goal())
-                        delete s;
-        delete p.root();
-        delete p.goal();
         return 0;
 }
index 53586221bc0a68da7626b4a54e6673190f1118c9..83fa5f27d8055314418406fba4a6e25a87e33653 100644 (file)
@@ -20,6 +20,18 @@ along with I am car. If not, see <http://www.gnu.org/licenses/>.
 #include "bcar.h"
 #include "rrtbase.h"
 
+RRTBase::~RRTBase()
+{
+        for (auto n: this->nodes_)
+                if (n != this->root_)
+                        delete n;
+        for (auto s: this->samples_)
+                if (s != this->goal_)
+                        delete s;
+        delete this->root_;
+        delete this->goal_;
+}
+
 RRTBase::RRTBase():
         root_(new RRTNode()),
         goal_(new RRTNode())
index a3efba2e713e3020a67f96878862a8ac6725f944..6f65389d2648993dd1d66900bb767bf314c71c8a 100644 (file)
@@ -49,6 +49,7 @@ class RRTBase {
                 const float GOAL_FOUND_DISTANCE = 0.2;
                 const float GOAL_FOUND_ANGLE = M_PI / 32;
 
+                ~RRTBase();
                 RRTBase();
                 RRTBase(RRTNode *init, RRTNode *goal);