Skip to content

Commit

Permalink
Proper drop fn
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelang committed Mar 13, 2019
1 parent a88d2ee commit ebe4596
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub use evmc_sys as ffi;
pub struct EvmcResult(Box<ffi::evmc_result>);

impl EvmcResult {
pub fn from_raw(*const ffi::evmc_result) -> Self {
EvmcResult(Box::from_raw(evmc_result))
}

pub fn release_result(self) {
if let Some(release_fn) = self.0.release {
unsafe {
Expand All @@ -34,3 +38,10 @@ impl EvmcResult {
self.0.gas_left = gas;
}
}

#[no_mangle]
pub extern "C" fn release_result(result: *const ffi::evmc_result) {
unsafe {
let to_drop = Box::from_raw(result);
}
}

0 comments on commit ebe4596

Please sign in to comment.