Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
justindbaur committed Aug 23, 2024
1 parent 497979e commit c5c8d17
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions crates/bitwarden-c/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type OnCompletedCallback = unsafe extern "C" fn(result: *mut c_char) -> ();
pub extern "C" fn run_command_async(
c_str_ptr: *const c_char,
client_ptr: *const CClient,
on_completed_callback: OnCompletedCallback
on_completed_callback: OnCompletedCallback,
) -> () {
let client = unsafe { ffi_ref!(client_ptr) };
let input_str = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr) }.to_bytes())
Expand All @@ -44,18 +44,16 @@ pub extern "C" fn run_command_async(
// so we need to make our own copy.
.to_owned();

client
.runtime
.spawn(async move {
let result = client.client.run_command(input_str.as_str()).await;
let str_result = match std::ffi::CString::new(result) {
Ok(cstr) => cstr.into_raw(),
Err(_) => panic!("failed to return comment result: null encountered"),
};
client.runtime.spawn(async move {
let result = client.client.run_command(input_str.as_str()).await;
let str_result = match std::ffi::CString::new(result) {
Ok(cstr) => cstr.into_raw(),
Err(_) => panic!("failed to return comment result: null encountered"),

Check warning on line 51 in crates/bitwarden-c/src/c.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-c/src/c.rs#L34-L51

Added lines #L34 - L51 were not covered by tests
};

// run completed function
unsafe { on_completed_callback(str_result) }
});
// run completed function
unsafe { on_completed_callback(str_result) }
});
}

Check warning on line 57 in crates/bitwarden-c/src/c.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-c/src/c.rs#L55-L57

Added lines #L55 - L57 were not covered by tests

// Init client, potential leak! You need to call free_mem after this!
Expand Down

0 comments on commit c5c8d17

Please sign in to comment.