Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: runtime/vm/growable_array.h

Issue 1293253005: Completely remove InterruptableThreadState and Fix ThreadRegistry leak (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // Defines growable array classes, that differ where they are allocated: 4 // Defines growable array classes, that differ where they are allocated:
5 // - GrowableArray: allocated on stack. 5 // - GrowableArray: allocated on stack.
6 // - ZoneGrowableArray: allocated in the zone. 6 // - ZoneGrowableArray: allocated in the zone.
7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called 7 // - MallocGrowableArray: allocates using malloc/realloc; free is only called
8 // at destruction. 8 // at destruction.
9 9
10 #ifndef VM_GROWABLE_ARRAY_H_ 10 #ifndef VM_GROWABLE_ARRAY_H_
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 void Reverse() { 93 void Reverse() {
94 for (intptr_t i = 0; i < length_ / 2; i++) { 94 for (intptr_t i = 0; i < length_ / 2; i++) {
95 const intptr_t j = length_ - 1 - i; 95 const intptr_t j = length_ - 1 - i;
96 T temp = data_[i]; 96 T temp = data_[i];
97 data_[i] = data_[j]; 97 data_[i] = data_[j];
98 data_[j] = temp; 98 data_[j] = temp;
99 } 99 }
100 } 100 }
101 101
102 // Swap entries |i| and |j|.
103 void Swap(intptr_t i, intptr_t j) {
104 ASSERT(i >= 0);
105 ASSERT(j >= 0);
106 ASSERT(i < length_);
107 ASSERT(j < length_);
108 T temp = data_[i];
109 data_[i] = data_[j];
110 data_[j] = temp;
111 }
112
102 // The content is uninitialized after calling it. 113 // The content is uninitialized after calling it.
103 void SetLength(intptr_t new_length); 114 void SetLength(intptr_t new_length);
104 115
105 // Sort the array in place. 116 // Sort the array in place.
106 inline void Sort(int compare(const T*, const T*)); 117 inline void Sort(int compare(const T*, const T*));
107 118
108 private: 119 private:
109 intptr_t length_; 120 intptr_t length_;
110 intptr_t capacity_; 121 intptr_t capacity_;
111 T* data_; 122 T* data_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 public: 222 public:
212 explicit MallocGrowableArray(intptr_t initial_capacity) 223 explicit MallocGrowableArray(intptr_t initial_capacity)
213 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {} 224 : BaseGrowableArray<T, EmptyBase, Malloc>(initial_capacity, NULL) {}
214 MallocGrowableArray() 225 MallocGrowableArray()
215 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {} 226 : BaseGrowableArray<T, EmptyBase, Malloc>(NULL) {}
216 }; 227 };
217 228
218 } // namespace dart 229 } // namespace dart
219 230
220 #endif // VM_GROWABLE_ARRAY_H_ 231 #endif // VM_GROWABLE_ARRAY_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698