[mlpack-git] master: Be safer with memory usage. (960e017)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Fri Jul 10 18:59:59 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/4a97187bbba7ce8a6191b714949dd818ef0f37d2...e5905e62c15d1bcff21e6359b11efcd7ab6d7ca0
>---------------------------------------------------------------
commit 960e01720f3feeeb30293c7ceb1d5f60d445dc88
Author: ryan <ryan at ratml.org>
Date: Tue Apr 21 16:08:00 2015 -0400
Be safer with memory usage.
>---------------------------------------------------------------
960e01720f3feeeb30293c7ceb1d5f60d445dc88
src/mlpack/core/tree/ballbound_impl.hpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/mlpack/core/tree/ballbound_impl.hpp b/src/mlpack/core/tree/ballbound_impl.hpp
index 8ada4a4..292cb62 100644
--- a/src/mlpack/core/tree/ballbound_impl.hpp
+++ b/src/mlpack/core/tree/ballbound_impl.hpp
@@ -253,6 +253,7 @@ BallBound<VecType, TMetricType>::operator|=(const MatType& data)
//! Serialize the BallBound.
template<typename VecType, typename TMetricType>
+template<typename Archive>
void BallBound<VecType, TMetricType>::Serialize(
Archive& ar,
const unsigned int /* version */)
@@ -262,11 +263,13 @@ void BallBound<VecType, TMetricType>::Serialize(
if (Archive::is_loading::value)
{
- metric = new TMetricType();
- ownsMetric = true;
+ // If we're loading, delete the local metric since we'll have a new one.
+ if (ownsMetric)
+ delete metric;
}
ar & data::CreateNVP(metric, "metric");
+ ar & data::CreateNVP(ownsMetric, "ownsMetric");
}
/**
More information about the mlpack-git
mailing list