diff options
author | 2015-02-13 10:28:29 +0000 | |
---|---|---|
committer | 2015-02-13 11:29:04 +0000 | |
commit | e4fcc5ba2284c201c022b52d27f7a1201d696324 (patch) | |
tree | 2f490060978baeb85c79d6184fcc08135f506637 /compiler/utils/growable_array.h | |
parent | 8240a8af33aedea9a4fe5c3b394d7c025ad081fb (diff) |
Clean up Scoped-/ArenaAlocator array allocations.
Change-Id: Id718f8a4450adf1608306286fa4e6b9194022532
Diffstat (limited to 'compiler/utils/growable_array.h')
-rw-r--r-- | compiler/utils/growable_array.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/compiler/utils/growable_array.h b/compiler/utils/growable_array.h index 6af4853e09..fd43ea6e20 100644 --- a/compiler/utils/growable_array.h +++ b/compiler/utils/growable_array.h @@ -33,16 +33,14 @@ class GrowableArray : public ArenaObject<kArenaAllocGrowableArray> { : arena_(arena), num_allocated_(init_length), num_used_(0) { - elem_list_ = static_cast<T*>(arena_->Alloc(sizeof(T) * init_length, - kArenaAllocGrowableArray)); + elem_list_ = arena_->AllocArray<T>(init_length, kArenaAllocGrowableArray); } GrowableArray(ArenaAllocator* arena, size_t init_length, T initial_data) : arena_(arena), num_allocated_(init_length), num_used_(init_length) { - elem_list_ = static_cast<T*>(arena_->Alloc(sizeof(T) * init_length, - kArenaAllocGrowableArray)); + elem_list_ = arena_->AllocArray<T>(init_length, kArenaAllocGrowableArray); for (size_t i = 0; i < init_length; ++i) { elem_list_[i] = initial_data; } @@ -58,8 +56,7 @@ class GrowableArray : public ArenaObject<kArenaAllocGrowableArray> { if (new_length > target_length) { target_length = new_length; } - T* new_array = static_cast<T*>(arena_->Alloc(sizeof(T) * target_length, - kArenaAllocGrowableArray)); + T* new_array = arena_->AllocArray<T>(target_length, kArenaAllocGrowableArray); memcpy(new_array, elem_list_, sizeof(T) * num_allocated_); num_allocated_ = target_length; elem_list_ = new_array; |