Unordered: delete/destroy/clear cleanup.

[SVN r80390]
This commit is contained in:
Daniel James
2012-09-03 20:06:00 +00:00
parent 8e5ffbbe6c
commit 32ab636fe8

View File

@ -516,25 +516,19 @@ namespace boost { namespace unordered { namespace detail {
return count; return count;
} }
void delete_extra_node(bucket_pointer) {}
void delete_extra_node(node_pointer n) {
node_allocator_traits::destroy(node_alloc(), boost::addressof(*n));
node_allocator_traits::deallocate(node_alloc(), n, 1);
}
void delete_buckets() void delete_buckets()
{ {
if(buckets_) { if(buckets_) {
previous_pointer prev = get_previous_start(); delete_nodes(get_start(), iterator());
while(prev->next_) { if (bucket::extra_node) {
node_pointer n = static_cast<node_pointer>(prev->next_); node_pointer n = static_cast<node_pointer>(
prev->next_ = n->next_; get_bucket(bucket_count_)->next_);
delete_node(iterator(n)); node_allocator_traits::destroy(node_alloc(),
boost::addressof(*n));
node_allocator_traits::deallocate(node_alloc(), n, 1);
} }
delete_extra_node(prev);
destroy_buckets(); destroy_buckets();
buckets_ = bucket_pointer(); buckets_ = bucket_pointer();
} }
@ -546,14 +540,8 @@ namespace boost { namespace unordered { namespace detail {
{ {
if(!size_) return; if(!size_) return;
previous_pointer prev = get_previous_start(); delete_nodes(get_start(), iterator());
get_previous_start()->next_ = link_pointer();
while(prev->next_) {
node_pointer n = static_cast<node_pointer>(prev->next_);
prev->next_ = n->next_;
delete_node(iterator(n));
}
clear_buckets(); clear_buckets();
BOOST_ASSERT(!size_); BOOST_ASSERT(!size_);
@ -581,6 +569,9 @@ namespace boost { namespace unordered { namespace detail {
buckets_, bucket_count_ + 1); buckets_, bucket_count_ + 1);
} }
////////////////////////////////////////////////////////////////////////
// Fix buckets after erase
// This is called after erasing a node or group of nodes to fix up // This is called after erasing a node or group of nodes to fix up
// the bucket pointers. // the bucket pointers.
void fix_buckets(bucket_pointer this_bucket, void fix_buckets(bucket_pointer this_bucket,