| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #ifndef TerminatedArray_h | 4 #ifndef TerminatedArray_h |
| 5 #define TerminatedArray_h | 5 #define TerminatedArray_h |
| 6 | 6 |
| 7 #include "wtf/Allocator.h" | 7 #include "wtf/Allocator.h" |
| 8 #include "wtf/PtrUtil.h" | 8 #include "wtf/PtrUtil.h" |
| 9 #include "wtf/allocator/Partitions.h" | 9 #include "wtf/allocator/Partitions.h" |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 iterator end() { return iterator(0); } | 68 iterator end() { return iterator(0); } |
| 69 const_iterator end() const { return const_iterator(0); } | 69 const_iterator end() const { return const_iterator(0); } |
| 70 | 70 |
| 71 size_t size() const { | 71 size_t size() const { |
| 72 size_t count = 0; | 72 size_t count = 0; |
| 73 for (const_iterator it = begin(); it != end(); ++it) | 73 for (const_iterator it = begin(); it != end(); ++it) |
| 74 count++; | 74 count++; |
| 75 return count; | 75 return count; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Match Allocator semantics to be able to use std::unique_ptr<TerminatedArray
>. | 78 // Match Allocator semantics to be able to use |
| 79 // std::unique_ptr<TerminatedArray>. |
| 79 void operator delete(void* p) { ::WTF::Partitions::fastFree(p); } | 80 void operator delete(void* p) { ::WTF::Partitions::fastFree(p); } |
| 80 | 81 |
| 81 private: | 82 private: |
| 82 // Allocator describes how TerminatedArrayBuilder should create new instances | 83 // Allocator describes how TerminatedArrayBuilder should create new instances |
| 83 // of TerminateArray and manage their lifetimes. | 84 // of TerminateArray and manage their lifetimes. |
| 84 struct Allocator { | 85 struct Allocator { |
| 85 STATIC_ONLY(Allocator); | 86 STATIC_ONLY(Allocator); |
| 86 using PassPtr = std::unique_ptr<TerminatedArray>; | 87 using PassPtr = std::unique_ptr<TerminatedArray>; |
| 87 using Ptr = std::unique_ptr<TerminatedArray>; | 88 using Ptr = std::unique_ptr<TerminatedArray>; |
| 88 | 89 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 107 | 108 |
| 108 template <typename, template <typename> class> | 109 template <typename, template <typename> class> |
| 109 friend class TerminatedArrayBuilder; | 110 friend class TerminatedArrayBuilder; |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 } // namespace WTF | 113 } // namespace WTF |
| 113 | 114 |
| 114 using WTF::TerminatedArray; | 115 using WTF::TerminatedArray; |
| 115 | 116 |
| 116 #endif // TerminatedArray_h | 117 #endif // TerminatedArray_h |
| OLD | NEW |