| Index: base/stack_container.h
|
| diff --git a/base/stack_container.h b/base/stack_container.h
|
| index dc946db6751f8503f07c6e0fd84edfcb1edf857b..06ef2a4f576804231d0bb5b597c3ec9482069063 100644
|
| --- a/base/stack_container.h
|
| +++ b/base/stack_container.h
|
| @@ -10,6 +10,7 @@
|
| #include <vector>
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/memory/aligned_memory.h"
|
|
|
| // This allocator can be used with STL containers to provide a stack buffer
|
| // from which to allocate memory and overflows onto the heap. This stack buffer
|
| @@ -43,22 +44,15 @@ class StackAllocator : public std::allocator<T> {
|
| }
|
|
|
| // Casts the buffer in its right type.
|
| - T* stack_buffer() { return reinterpret_cast<T*>(stack_buffer_); }
|
| + T* stack_buffer() { return stack_buffer_.template data_as<T>(); }
|
| const T* stack_buffer() const {
|
| - return reinterpret_cast<const T*>(stack_buffer_);
|
| + return stack_buffer_.template data_as<T>();
|
| }
|
|
|
| - //
|
| - // IMPORTANT: Take care to ensure that stack_buffer_ is aligned
|
| - // since it is used to mimic an array of T.
|
| - // Be careful while declaring any unaligned types (like bool)
|
| - // before stack_buffer_.
|
| - //
|
| -
|
| // The buffer itself. It is not of type T because we don't want the
|
| // constructors and destructors to be automatically called. Define a POD
|
| // buffer of the right size instead.
|
| - char stack_buffer_[sizeof(T[stack_capacity])];
|
| + base::AlignedMemory<sizeof(T[stack_capacity]), ALIGNOF(T)> stack_buffer_;
|
|
|
| // Set when the stack buffer is used for an allocation. We do not track
|
| // how much of the buffer is used, only that somebody is using it.
|
|
|