summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-08-29 22:35:29 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-08-29 22:35:29 +0200
commit14567c5eb05b6dd7ba9706a605c8d3ee8c5d8742 (patch)
treeae3128c03ec2f964e19f842f4b31784906e75136 /src/rt/rust_builtin.cpp
parenteb4661fc5292ea364f5ee976d9112fe7edcb13ca (diff)
downloadrust-14567c5eb05b6dd7ba9706a605c8d3ee8c5d8742.tar.gz
rust-14567c5eb05b6dd7ba9706a605c8d3ee8c5d8742.zip
Factor vector reserve code in runtime into its own function
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index a8929677aff..049fe71384e 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -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);
 }
 
 /**