Factor vector reserve code in runtime into its own function

This commit is contained in:
Marijn Haverbeke
2011-08-29 22:35:29 +02:00
parent eb4661fc52
commit 14567c5eb0
3 changed files with 13 additions and 21 deletions

View File

@@ -225,13 +225,7 @@ str_from_vec(rust_task *task, rust_vec **vp)
extern "C" CDECL void
vec_reserve_shared(rust_task* task, type_desc* ty, rust_vec** vp,
size_t n_elts) {
size_t new_sz = n_elts * ty->size;
if (new_sz > (*vp)->alloc) {
size_t new_alloc = next_power_of_two(new_sz);
*vp = (rust_vec*)task->kernel->realloc(*vp, new_alloc +
sizeof(rust_vec));
(*vp)->alloc = new_alloc;
}
reserve_vec(task, vp, n_elts * ty->size);
}
/**