diff --git a/c-api/libvmexeccapi.h b/c-api/libvmexeccapi.h index f4a0da9..c7b77ad 100644 --- a/c-api/libvmexeccapi.h +++ b/c-api/libvmexeccapi.h @@ -317,7 +317,7 @@ vm_exec_result_t vm_check_signatures(vm_exec_instance_t *instance_ptr); * * C API function, works with raw object pointers. */ -void vm_exec_executor_destroy(vm_exec_executor_t *executor); +void vm_exec_executor_destroy(vm_exec_executor_t *executor_ptr); /** * Sets the data that can be hold by an instance context. @@ -380,7 +380,7 @@ vm_exec_result_t vm_exec_instance_call(vm_exec_instance_t *instance_ptr, const c * * C API function, works with raw object pointers. */ -void vm_exec_instance_destroy(vm_exec_instance_t *instance); +void vm_exec_instance_destroy(vm_exec_instance_t *instance_ptr); /** * Creates a new VM executor instance from cache. diff --git a/c-api/src/capi_executor.rs b/c-api/src/capi_executor.rs index 45eac2f..3293054 100644 --- a/c-api/src/capi_executor.rs +++ b/c-api/src/capi_executor.rs @@ -97,8 +97,9 @@ pub unsafe extern "C" fn vm_exec_executor_set_vm_hooks_ptr( /// C API function, works with raw object pointers. #[allow(clippy::cast_ptr_alignment)] #[no_mangle] -pub unsafe extern "C" fn vm_exec_executor_destroy(executor: *mut vm_exec_executor_t) { - if !executor.is_null() { - std::ptr::drop_in_place(executor); +pub unsafe extern "C" fn vm_exec_executor_destroy(executor_ptr: *mut vm_exec_executor_t) { + if !executor_ptr.is_null() { + let executor = Box::from_raw(executor_ptr as *mut CapiExecutor); + drop(executor) } } diff --git a/c-api/src/capi_instance.rs b/c-api/src/capi_instance.rs index cdce869..689e70d 100644 --- a/c-api/src/capi_instance.rs +++ b/c-api/src/capi_instance.rs @@ -214,9 +214,10 @@ pub unsafe extern "C" fn vm_exported_function_names( /// C API function, works with raw object pointers. #[allow(clippy::cast_ptr_alignment)] #[no_mangle] -pub unsafe extern "C" fn vm_exec_instance_destroy(instance: *mut vm_exec_instance_t) { - if !instance.is_null() { - std::ptr::drop_in_place(instance); +pub unsafe extern "C" fn vm_exec_instance_destroy(instance_ptr: *mut vm_exec_instance_t) { + if !instance_ptr.is_null() { + let instance = Box::from_raw(instance_ptr as *mut CapiInstance); + drop(instance); } } diff --git a/vm-executor-wasmer/src/wasmer_service.rs b/vm-executor-wasmer/src/wasmer_service.rs index bda8f97..9000c03 100644 --- a/vm-executor-wasmer/src/wasmer_service.rs +++ b/vm-executor-wasmer/src/wasmer_service.rs @@ -3,8 +3,8 @@ use multiversx_chain_vm_executor::{ Executor, ExecutorError, ExecutorLastError, ExecutorService, VMHooks, }; -// use log::LevelFilter; -// use crate::wasmer_logger as WasmerLogger; +use log::LevelFilter; +use crate::wasmer_logger as WasmerLogger; use crate::WasmerExecutor; #[derive(Default)] @@ -22,7 +22,7 @@ impl BasicExecutorService { fn init() { // Initialize the logger only once (disable until we sync with node) - // WasmerLogger::init(LevelFilter::Off); + WasmerLogger::init(LevelFilter::Off); } }