Skip to content

Commit f973421

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 14069 b: refs/heads/try c: d3dfe87 h: refs/heads/master i: 14067: e57f782 v: v3
1 parent 7f9fea3 commit f973421

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
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 9f0239ce9c24972e8f50b4161130414965886348
5+
refs/heads/try: d3dfe8758d674d41c3aae116385bcc2b992413ed
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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/try/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)