Skip to content

Commit 65b66e8

Browse files
refactor: streamline memory allocation in wallet_build_and_sign_transaction
This commit simplifies the memory allocation process for the transaction bytes in the wallet_build_and_sign_transaction function by removing an unnecessary match statement. The updated code directly allocates and converts the boxed slice into a raw pointer, improving readability and maintainability.
1 parent 0551e01 commit 65b66e8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

key-wallet-ffi/src/transaction.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,8 @@ pub unsafe extern "C" fn wallet_build_and_sign_transaction(
421421
let size = serialized.len();
422422

423423
// Allocate memory for the result
424-
let tx_bytes = match Vec::<u8>::with_capacity(size).into_boxed_slice() {
425-
bytes => Box::into_raw(bytes) as *mut u8,
426-
};
424+
let bytes = Vec::<u8>::with_capacity(size).into_boxed_slice();
425+
let tx_bytes = Box::into_raw(bytes) as *mut u8;
427426

428427
// Copy the serialized transaction
429428
ptr::copy_nonoverlapping(serialized.as_ptr(), tx_bytes, size);

0 commit comments

Comments
 (0)