URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-09-25 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Update memory managment for run_images.
* mln/core/rle_image.hh,
* mln/core/sparse_image.hh: Move the data allocation to the insert
method.
---
rle_image.hh | 6 ++----
sparse_image.hh | 6 ++----
2 files changed, 4 insertions(+), 8 deletions(-)
Index: trunk/milena/mln/core/rle_image.hh
===================================================================
--- trunk/milena/mln/core/rle_image.hh (revision 1168)
+++ trunk/milena/mln/core/rle_image.hh (revision 1169)
@@ -125,10 +125,6 @@
template <typename P, typename T>
rle_image<P, T>::rle_image()
{
- // FIXME : ambiguity between empty constructor and constructor
- // which allocate data_
-
- // this->data_ = new internal::data_< rle_image<I,T> >();
}
template <typename P, typename T>
@@ -149,6 +145,8 @@
void
rle_image<P, T>::insert(const P& p, unsigned len, T value)
{
+ if (!this->has_data())
+ this->data_ = new internal::data_< rle_image<P,T> >();
this->data_->domain_.insert(p, len);
this->data_->values_.push_back(value);
}
Index: trunk/milena/mln/core/sparse_image.hh
===================================================================
--- trunk/milena/mln/core/sparse_image.hh (revision 1168)
+++ trunk/milena/mln/core/sparse_image.hh (revision 1169)
@@ -121,10 +121,6 @@
template <typename P, typename T>
sparse_image<P, T>::sparse_image()
{
- // FIXME : ambiguity between empty constructor and constructor
- // which allocate data_
-
- // this->data_ = new internal::data_< sparse_image<I,T> >();
}
template <typename P, typename T>
@@ -146,6 +142,8 @@
sparse_image<P, T>::insert(const P& p, unsigned len,
const std::vector<T>& value)
{
+ if (!this->has_data())
+ this->data_ = new internal::data_< sparse_image<P,T> >();
this->data_->domain_.insert(p, len);
this->data_->values_.push_back(value);
}