| 187 | capacity = new_capacity; |
| 188 | } |
| 189 | inline void commit(int new_capacity) |
| 190 | { |
| 191 | uint64_t current_bytes = _round_up_to_page(capacity * sizeof(T)); |
| 192 | uint64_t new_bytes = _round_up_to_page(new_capacity * sizeof(T)); |
| 193 | |
| 194 | if (new_bytes <= current_bytes) |
| 195 | { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | assert(new_bytes < reserved_bytes); |
| 200 | char* data_bytes = (char*)data; |
| 201 | VirtualAlloc(data_bytes + current_bytes, new_bytes - current_bytes, MEM_COMMIT, PAGE_READWRITE); |
| 202 | capacity = new_capacity; |
| 203 | } |
| 204 | |
| 205 | // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the w_vector data itself! e.g. v.push_back(v[10]) is forbidden. |
| 206 | inline T* push_back(const T& v) { |