Skip to content

Commit 8358ba0

Browse files
authored
baseline: Refactor code padding (#517)
Use std::make_unique_for_overwrite to create padded code.
1 parent 2205fb3 commit 8358ba0

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/evmone/baseline.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ std::unique_ptr<uint8_t[]> pad_code(bytes_view code)
5353
// instruction at the code end.
5454
constexpr auto padding = 32 + 1;
5555

56-
// Using "raw" new operator instead of std::make_unique() to get uninitialized array.
57-
std::unique_ptr<uint8_t[]> padded_code{new uint8_t[code.size() + padding]};
56+
auto padded_code = std::make_unique_for_overwrite<uint8_t[]>(code.size() + padding);
5857
std::copy(std::begin(code), std::end(code), padded_code.get());
5958
std::fill_n(&padded_code[code.size()], padding, uint8_t{OP_STOP});
6059
return padded_code;

0 commit comments

Comments
 (0)