diff options
Diffstat (limited to 'absl/container')
-rw-r--r-- | absl/container/fixed_array.h | 8 | ||||
-rw-r--r-- | absl/container/fixed_array_test.cc | 1 |
2 files changed, 3 insertions, 6 deletions
diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h index 1fec9d2b3784..b92d90564d21 100644 --- a/absl/container/fixed_array.h +++ b/absl/container/fixed_array.h @@ -458,7 +458,7 @@ class FixedArray { // Loop optimizes to nothing for trivially destructible T. for (Holder* p = end(); p != begin();) (--p)->~Holder(); if (IsAllocated(size())) { - ::operator delete[](begin()); + std::allocator<Holder>().deallocate(p_, n_); } else { this->AnnotateDestruct(size()); } @@ -470,17 +470,13 @@ class FixedArray { private: Holder* MakeHolder(size_type n) { if (IsAllocated(n)) { - return Allocate(n); + return std::allocator<Holder>().allocate(n); } else { this->AnnotateConstruct(n); return this->data(); } } - Holder* Allocate(size_type n) { - return static_cast<Holder*>(::operator new[](n * sizeof(Holder))); - } - bool IsAllocated(size_type n) const { return n > inline_elements; } const size_type n_; diff --git a/absl/container/fixed_array_test.cc b/absl/container/fixed_array_test.cc index b6782f517a6c..2142132d1352 100644 --- a/absl/container/fixed_array_test.cc +++ b/absl/container/fixed_array_test.cc @@ -504,6 +504,7 @@ struct PickyDelete { TEST(FixedArrayTest, UsesGlobalAlloc) { absl::FixedArray<PickyDelete, 0> a(5); } + TEST(FixedArrayTest, Data) { static const int kInput[] = { 2, 3, 5, 7, 11, 13, 17 }; absl::FixedArray<int> fa(std::begin(kInput), std::end(kInput)); |