From f2cd0eb69a024e78caa3ca38c7e457f297b35286 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 13 Oct 2022 17:06:23 +0200 Subject: [PATCH] Remove unnecessary Box roundtrip in Dialog accessors --- native/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/src/lib.rs b/native/src/lib.rs index 249f743..9e18a39 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -181,7 +181,7 @@ pub unsafe extern "C" fn Java_dev_lonami_talaria_bindings_Native_dialogCount( _: JObject, dialogs_ptr: jlong, ) -> jint { - let dialogs = Box::leak(Box::from_raw(dialogs_ptr as *mut Vec)); + let dialogs = &mut *(dialogs_ptr as *mut Vec); dialogs.len() as jint } @@ -192,7 +192,7 @@ pub unsafe extern "C" fn Java_dev_lonami_talaria_bindings_Native_dialogPacked( dialogs_ptr: jlong, index: jint, ) -> jstring { - let dialogs = Box::leak(Box::from_raw(dialogs_ptr as *mut Vec)); + let dialogs = &mut *(dialogs_ptr as *mut Vec); let packed = dialogs[index as usize].chat().pack().to_hex(); let output = env.new_string(packed).unwrap(); @@ -206,7 +206,7 @@ pub unsafe extern "C" fn Java_dev_lonami_talaria_bindings_Native_dialogTitle( dialogs_ptr: jlong, index: jint, ) -> jstring { - let dialogs = Box::leak(Box::from_raw(dialogs_ptr as *mut Vec)); + let dialogs = &mut *(dialogs_ptr as *mut Vec); let title = dialogs[index as usize].chat().name(); let output = env.new_string(title).unwrap();