Commit 16b569f8 authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Don't use deprecated std::allocator<T>::allocate() overload in base::StackContainer

`allocate()` with a hint is deprecated in C++17 and removed in C++20.
Note that while `allocate(size_t)` isn't provided prior to C++17,
`allocate(size_t, void* = nullptr)` is and will behave equivalently.

Bug: 752720
Fixed: 1065435
Change-Id: I27a7a22a752e8304988f44d9a2e330a6b2b97db5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2131045Reviewed-by: default avatarTiancong Wang <tcwang@google.com>
Reviewed-by: default avatarGeorge Burgess <gbiv@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755425}
parent d2577c92
......@@ -102,20 +102,19 @@ class StackAllocator : public std::allocator<T> {
// Actually do the allocation. Use the stack buffer if nobody has used it yet
// and the size requested fits. Otherwise, fall through to the standard
// allocator.
pointer allocate(size_type n, void* hint = 0) {
if (source_ != NULL && !source_->used_stack_buffer_
&& n <= stack_capacity) {
pointer allocate(size_type n) {
if (source_ && !source_->used_stack_buffer_ && n <= stack_capacity) {
source_->used_stack_buffer_ = true;
return source_->stack_buffer();
} else {
return std::allocator<T>::allocate(n, hint);
return std::allocator<T>::allocate(n);
}
}
// Free: when trying to free the stack buffer, just mark it as free. For
// non-stack-buffer pointers, just fall though to the standard allocator.
void deallocate(pointer p, size_type n) {
if (source_ != NULL && p == source_->stack_buffer())
if (source_ && p == source_->stack_buffer())
source_->used_stack_buffer_ = false;
else
std::allocator<T>::deallocate(p, n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment