Index: src/list-inl.h |
diff --git a/src/list-inl.h b/src/list-inl.h |
index 6cf3badc623b92e20095e208677e3f4d809de5c1..3eff5826a33d8623515f0650694a174ebc40b49a 100644 |
--- a/src/list-inl.h |
+++ b/src/list-inl.h |
@@ -35,25 +35,25 @@ namespace internal { |
template<typename T, class P> |
-void List<T, P>::Add(const T& element) { |
+void List<T, P>::Add(const T& element, P alloc) { |
if (length_ < capacity_) { |
data_[length_++] = element; |
} else { |
- List<T, P>::ResizeAdd(element); |
+ List<T, P>::ResizeAdd(element, alloc); |
} |
} |
template<typename T, class P> |
-void List<T, P>::AddAll(const List<T, P>& other) { |
- AddAll(other.ToVector()); |
+void List<T, P>::AddAll(const List<T, P>& other, P alloc) { |
+ AddAll(other.ToVector(), alloc); |
} |
template<typename T, class P> |
-void List<T, P>::AddAll(const Vector<T>& other) { |
+void List<T, P>::AddAll(const Vector<T>& other, P alloc) { |
int result_length = length_ + other.length(); |
- if (capacity_ < result_length) Resize(result_length); |
+ if (capacity_ < result_length) Resize(result_length, alloc); |
for (int i = 0; i < other.length(); i++) { |
data_[length_ + i] = other.at(i); |
} |
@@ -64,13 +64,13 @@ void List<T, P>::AddAll(const Vector<T>& other) { |
// Use two layers of inlining so that the non-inlined function can |
// use the same implementation as the inlined version. |
template<typename T, class P> |
-void List<T, P>::ResizeAdd(const T& element) { |
- ResizeAddInternal(element); |
+void List<T, P>::ResizeAdd(const T& element, P alloc) { |
+ ResizeAddInternal(element, alloc); |
} |
template<typename T, class P> |
-void List<T, P>::ResizeAddInternal(const T& element) { |
+void List<T, P>::ResizeAddInternal(const T& element, P alloc) { |
ASSERT(length_ >= capacity_); |
// Grow the list capacity by 100%, but make sure to let it grow |
// even when the capacity is zero (possible initial case). |
@@ -78,14 +78,14 @@ void List<T, P>::ResizeAddInternal(const T& element) { |
// Since the element reference could be an element of the list, copy |
// it out of the old backing storage before resizing. |
T temp = element; |
- Resize(new_capacity); |
+ Resize(new_capacity, alloc); |
data_[length_++] = temp; |
} |
template<typename T, class P> |
-void List<T, P>::Resize(int new_capacity) { |
- T* new_data = List<T, P>::NewData(new_capacity); |
+void List<T, P>::Resize(int new_capacity, P alloc) { |
+ T* new_data = NewData(new_capacity, alloc); |
memcpy(new_data, data_, capacity_ * sizeof(T)); |
List<T, P>::DeleteData(data_); |
data_ = new_data; |
@@ -94,17 +94,17 @@ void List<T, P>::Resize(int new_capacity) { |
template<typename T, class P> |
-Vector<T> List<T, P>::AddBlock(T value, int count) { |
+Vector<T> List<T, P>::AddBlock(T value, int count, P alloc) { |
int start = length_; |
- for (int i = 0; i < count; i++) Add(value); |
+ for (int i = 0; i < count; i++) Add(value, alloc); |
return Vector<T>(&data_[start], count); |
} |
template<typename T, class P> |
-void List<T, P>::InsertAt(int index, const T& elm) { |
+void List<T, P>::InsertAt(int index, const T& elm, P alloc) { |
ASSERT(index >= 0 && index <= length_); |
- Add(elm); |
+ Add(elm, alloc); |
for (int i = length_ - 1; i > index; --i) { |
data_[i] = data_[i - 1]; |
} |
@@ -137,9 +137,9 @@ bool List<T, P>::RemoveElement(const T& elm) { |
template<typename T, class P> |
-void List<T, P>::Allocate(int length) { |
+void List<T, P>::Allocate(int length, P allocator) { |
DeleteData(data_); |
- Initialize(length); |
+ Initialize(length, allocator); |
length_ = length; |
} |
@@ -207,9 +207,9 @@ void List<T, P>::Sort() { |
template<typename T, class P> |
-void List<T, P>::Initialize(int capacity) { |
+void List<T, P>::Initialize(int capacity, P allocator) { |
ASSERT(capacity >= 0); |
- data_ = (capacity > 0) ? NewData(capacity) : NULL; |
+ data_ = (capacity > 0) ? NewData(capacity, allocator) : NULL; |
capacity_ = capacity; |
length_ = 0; |
} |