[Base] Make Arena alignment aware

- Add align parameter
- Templated Alloc() implicitly aligns type correctly
- Rewind may leak padding that was added due to alignment
This commit is contained in:
Joel Linn
2021-06-03 03:55:57 +02:00
committed by Rick Gibbed
parent d8cfeac79f
commit 86722be9ca
7 changed files with 43 additions and 22 deletions

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2020 Ben Vanik. All rights reserved. *
* Copyright 2021 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -739,7 +739,7 @@ void HIRBuilder::Comment(std::string_view value) {
return;
}
auto size = value.size();
auto p = reinterpret_cast<char*>(arena_->Alloc(size + 1));
auto p = reinterpret_cast<char*>(arena_->Alloc(size + 1, 1));
std::memcpy(p, value.data(), size);
p[size] = '\0';
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);
@@ -752,7 +752,7 @@ void HIRBuilder::Comment(const StringBuffer& value) {
return;
}
auto size = value.length();
auto p = reinterpret_cast<char*>(arena_->Alloc(size + 1));
auto p = reinterpret_cast<char*>(arena_->Alloc(size + 1, 1));
std::memcpy(p, value.buffer(), size);
p[size] = '\0';
Instr* i = AppendInstr(OPCODE_COMMENT_info, 0);