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
3 // found in the LICENSE file.
5 #ifndef HeapTerminatedArray_h
6 #define HeapTerminatedArray_h
8 #include "platform/heap/Heap.h"
9 #include "wtf/TerminatedArray.h"
10 #include "wtf/TerminatedArrayBuilder.h"
15 class HeapTerminatedArray : public TerminatedArray<T> {
16 DISALLOW_ALLOCATION();
18 using TerminatedArray<T>::begin;
19 using TerminatedArray<T>::end;
21 void trace(Visitor* visitor)
23 for (typename TerminatedArray<T>::iterator it = begin(); it != end(); ++it)
28 // Allocator describes how HeapTerminatedArrayBuilder should create new intances
29 // of TerminateArray and manage their lifetimes.
31 typedef HeapTerminatedArray* PassPtr;
32 typedef RawPtr<HeapTerminatedArray> Ptr;
34 static PassPtr create(size_t capacity)
36 return reinterpret_cast<HeapTerminatedArray*>(Heap::allocate<HeapTerminatedArray>(capacity * sizeof(T)));
39 static PassPtr resize(PassPtr ptr, size_t capacity)
41 return reinterpret_cast<HeapTerminatedArray*>(Heap::reallocate<HeapTerminatedArray>(ptr, capacity * sizeof(T)));
45 // Prohibit construction. Allocator makes HeapTerminatedArray instances for
46 // HeapTerminatedArrayBuilder by pointer casting.
47 HeapTerminatedArray();
49 template<typename U, template <typename> class> friend class WTF::TerminatedArrayBuilder;
54 #endif // HeapTerminatedArray_h