Skip to content

Commit 811f20d

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 8083 b: refs/heads/snap-stage3 c: d3dfe87 h: refs/heads/master i: 8081: 07174e7 8079: 6f6dd8b v: v3
1 parent 89775e7 commit 811f20d

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 9f0239ce9c24972e8f50b4161130414965886348
4+
refs/heads/snap-stage3: d3dfe8758d674d41c3aae116385bcc2b992413ed
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ extern "C" CDECL void
102102
vec_reserve_shared(type_desc* ty, rust_vec** vp,
103103
size_t n_elts) {
104104
rust_task *task = rust_task_thread::get_task();
105-
reserve_vec(task, vp, n_elts * ty->size);
105+
reserve_vec_exact(task, vp, n_elts * ty->size);
106106
}
107107

108108
/**

branches/snap-stage3/src/rt/rust_util.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,17 @@ inline size_t vec_size(size_t elems) {
178178
return sizeof(rust_vec) + sizeof(T) * elems;
179179
}
180180

181-
inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
181+
inline void reserve_vec_exact(rust_task* task, rust_vec** vpp, size_t size) {
182182
if (size > (*vpp)->alloc) {
183-
size_t new_alloc = next_power_of_two(size);
184-
*vpp = (rust_vec*)task->kernel->realloc(*vpp, new_alloc +
185-
sizeof(rust_vec));
186-
(*vpp)->alloc = new_alloc;
183+
*vpp = (rust_vec*)task->kernel->realloc(*vpp, size + sizeof(rust_vec));
184+
(*vpp)->alloc = size;
187185
}
188186
}
189187

188+
inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
189+
reserve_vec_exact(task, vpp, next_power_of_two(size));
190+
}
191+
190192
typedef rust_vec rust_str;
191193

192194
inline rust_str *

0 commit comments

Comments
 (0)