diff --git a/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h b/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h index eedc22d..c808e79 100644 --- a/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h +++ b/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h @@ -113,14 +113,17 @@ allocate_rec(int node, Type& element) { int pool_index = NodeIndexToPoolIndex(node); Type expected = pool_[pool_index]; - if (expected == Undefined) + if (expected == Undefined) { + element = Type(); return -1; + } if (pool_[pool_index].CompareAndSwap(expected, Undefined)) { element = expected; return pool_index; } + element = Type(); return -1; } diff --git a/containers_cpp/test/hazard_pointer_test.cc b/containers_cpp/test/hazard_pointer_test.cc index c005149..b2d2baa 100644 --- a/containers_cpp/test/hazard_pointer_test.cc +++ b/containers_cpp/test/hazard_pointer_test.cc @@ -144,6 +144,7 @@ void HazardPointerTest::HazardPointerTest1ThreadMethod() { for (int i = 0; i != n_elements_per_thread_; ++i) { embb::base::Atomic* allocated_object = object_pool_->Allocate(0); + PT_ASSERT(NULL != allocated_object); hazard_pointer_->Guard(0, allocated_object); @@ -248,6 +249,7 @@ void HazardPointerTest2::HazardPointerTest2Master() { // while the hazard pointer guard array is not full int** allocatedLocal = static_cast( embb::base::Allocation::Allocate(sizeof(int*)*guaranteed_capacity_pool_)); + PT_ASSERT(NULL != allocatedLocal); bool full = false; while (!full) { @@ -295,16 +297,19 @@ void HazardPointerTest2::HazardPointerTest2Pre() { // first the test pool has to be created test_pool_ = embb::base::Allocation::New (pool_size_using_hazard_pointer_); + PT_ASSERT(NULL != test_pool_); // after the pool has been created, we create the hp class hazard_pointer_ = embb::base::Allocation::New < embb::containers::internal::HazardPointer > (delete_pointer_callback_, static_cast(NULL), static_cast(guards_per_phread_count_), n_threads); + PT_ASSERT(NULL != hazard_pointer_); shared_guarded_ = static_cast*>( embb::base::Allocation::Allocate(sizeof(embb::base::Atomic)* guaranteed_capacity_pool_)); + PT_ASSERT(NULL != shared_guarded_); for (unsigned int i = 0; i != guaranteed_capacity_pool_; ++i) { // in-place new for each array cell