
Module: ppl/ppl Branch: master Commit: db4eb1cdc83424041c699891a22639bf8106f3d0 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=db4eb1cdc8342...
Author: Marco Poletti poletti.marco@gmail.com Date: Sun Dec 4 00:31:01 2011 +0100
CO_Tree: avoid static_casts between Coefficient* and void*. Use an allocator instead.
---
src/CO_Tree.cc | 8 +++----- src/CO_Tree.defs.hh | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc index 08115c2..f2f5c66 100644 --- a/src/CO_Tree.cc +++ b/src/CO_Tree.cc @@ -521,8 +521,7 @@ PPL::CO_Tree::init(dimension_type reserved_size1) { reserved_size = ((dimension_type)1 << max_depth) - 1; indexes = new dimension_type[reserved_size + 2]; try { - data = static_cast<data_type*>(operator new(sizeof(data_type) - * (reserved_size + 1))); + data = coefficient_allocator.allocate(reserved_size + 1); } catch (...) { delete [] indexes; throw; @@ -551,7 +550,7 @@ PPL::CO_Tree::destroy() { }
delete [] indexes; - operator delete(static_cast<void*>(data)); + coefficient_allocator.deallocate(data, reserved_size + 1); } }
@@ -705,8 +704,7 @@ PPL::CO_Tree::rebuild_bigger_tree() { data_type* new_data;
try { - new_data = static_cast<data_type*>(operator new(sizeof(data_type) - * (new_reserved_size + 1))); + new_data = coefficient_allocator.allocate(new_reserved_size + 1); } catch (...) { delete new_indexes; throw; diff --git a/src/CO_Tree.defs.hh b/src/CO_Tree.defs.hh index 86a3a2f..eed941c 100644 --- a/src/CO_Tree.defs.hh +++ b/src/CO_Tree.defs.hh @@ -1299,6 +1299,8 @@ private:
//! The number of values stored in the tree. dimension_type size_; + + std::allocator<Coefficient> coefficient_allocator; };
class CO_Tree::tree_iterator {