Merge pull request #286 from ethereum/rust-result-simplify

rust: remove code duplication in ExecutionResult
This commit is contained in:
Alex Beregszaszi 2019-05-22 17:18:07 +01:00 committed by GitHub
commit 8c19e445fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 10 deletions

View File

@ -296,16 +296,9 @@ unsafe fn deallocate_output_data(ptr: *const u8, size: usize) {
/// Returns a pointer to a heap-allocated evmc_result.
impl Into<*const ffi::evmc_result> for ExecutionResult {
fn into(self) -> *const ffi::evmc_result {
let (buffer, len) = allocate_output_data(self.output);
Box::into_raw(Box::new(ffi::evmc_result {
status_code: self.status_code,
gas_left: self.gas_left,
output_data: buffer,
output_size: len,
release: Some(release_heap_result),
create_address: self.create_address,
padding: [0u8; 4],
}))
let mut result: ffi::evmc_result = self.into();
result.release = Some(release_heap_result);
Box::into_raw(Box::new(result))
}
}