forked from Lonami/Talaria
Remove unnecessary Box roundtrip in Dialog accessors
This commit is contained in:
parent
e1985e8c73
commit
f2cd0eb69a
|
@ -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<Dialog>));
|
||||
let dialogs = &mut *(dialogs_ptr as *mut Vec<Dialog>);
|
||||
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<Dialog>));
|
||||
let dialogs = &mut *(dialogs_ptr as *mut Vec<Dialog>);
|
||||
|
||||
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<Dialog>));
|
||||
let dialogs = &mut *(dialogs_ptr as *mut Vec<Dialog>);
|
||||
|
||||
let title = dialogs[index as usize].chat().name();
|
||||
let output = env.new_string(title).unwrap();
|
||||
|
|
Loading…
Reference in New Issue