diff options
Diffstat (limited to 'compiler/utils/growable_array.h')
-rw-r--r-- | compiler/utils/growable_array.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/utils/growable_array.h b/compiler/utils/growable_array.h index fde65e79c3..b84842910b 100644 --- a/compiler/utils/growable_array.h +++ b/compiler/utils/growable_array.h @@ -37,6 +37,18 @@ class GrowableArray : public ArenaObject<kArenaAllocGrowableArray> { kArenaAllocGrowableArray)); } + GrowableArray(ArenaAllocator* arena, size_t init_length, T initial_data) + : arena_(arena), + num_allocated_(init_length), + num_used_(0) { + SetSize(init_length); + elem_list_ = static_cast<T*>(arena_->Alloc(sizeof(T) * init_length, + kArenaAllocGrowableArray)); + for (size_t i = 0; i < init_length; ++i) { + elem_list_[i] = initial_data; + } + } + // Expand the list size to at least new length. void Resize(size_t new_length) { |