Making vec::reserve reserve precisely the size given (untested)
This commit is contained in:
committed by
Brian Anderson
parent
9f0239ce9c
commit
d3dfe8758d
@@ -178,15 +178,17 @@ inline size_t vec_size(size_t elems) {
|
||||
return sizeof(rust_vec) + sizeof(T) * elems;
|
||||
}
|
||||
|
||||
inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
|
||||
inline void reserve_vec_exact(rust_task* task, rust_vec** vpp, size_t size) {
|
||||
if (size > (*vpp)->alloc) {
|
||||
size_t new_alloc = next_power_of_two(size);
|
||||
*vpp = (rust_vec*)task->kernel->realloc(*vpp, new_alloc +
|
||||
sizeof(rust_vec));
|
||||
(*vpp)->alloc = new_alloc;
|
||||
*vpp = (rust_vec*)task->kernel->realloc(*vpp, size + sizeof(rust_vec));
|
||||
(*vpp)->alloc = size;
|
||||
}
|
||||
}
|
||||
|
||||
inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
|
||||
reserve_vec_exact(task, vpp, next_power_of_two(size));
|
||||
}
|
||||
|
||||
typedef rust_vec rust_str;
|
||||
|
||||
inline rust_str *
|
||||
|
||||
Reference in New Issue
Block a user