diff --git a/tools/db_stress.cc b/tools/db_stress.cc index ce4128052..f291934ba 100644 --- a/tools/db_stress.cc +++ b/tools/db_stress.cc @@ -888,8 +888,9 @@ class SharedState { } } if (values_ == nullptr) { - values_ = - static_cast*>(malloc(expected_values_size)); + values_allocation_.reset( + new std::atomic[FLAGS_column_families * max_key_]); + values_ = &values_allocation_[0]; values_init_needed = true; } assert(values_ != nullptr); @@ -1116,6 +1117,7 @@ class SharedState { std::vector > no_overwrite_ids_; std::atomic* values_; + std::unique_ptr[]> values_allocation_; // Has to make it owned by a smart ptr as port::Mutex is not copyable // and storing it in the container may require copying depending on the impl. std::vector > > key_locks_;