From 9c33e491f236e2664edbe92fb4f1c0130a349763 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Tue, 20 Feb 2024 10:38:59 -0700 Subject: [PATCH] Use next_multiple_of instead of bitshifts --- ctru-rs/src/applets/swkbd.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index a9e4a51..93f69ec 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -647,13 +647,13 @@ impl SoftwareKeyboard { // Calculate shared mem size let mut shared_mem_size = 0; - shared_mem_size += - (std::mem::size_of::() * (swkbd.max_text_len as usize + 1) + 3) & !3; + shared_mem_size += (std::mem::size_of::() * (swkbd.max_text_len as usize + 1)) + .next_multiple_of(std::mem::size_of::()); let dict_off = shared_mem_size; - shared_mem_size += - (std::mem::size_of::() * swkbd.dict_word_count as usize + 3) & !3; + shared_mem_size += (std::mem::size_of::() * swkbd.dict_word_count as usize) + .next_multiple_of(std::mem::size_of::()); let status_off = shared_mem_size; @@ -681,7 +681,7 @@ impl SoftwareKeyboard { shared_mem_size += std::mem::size_of::(); } - shared_mem_size = (shared_mem_size + 0xFFF) & !0xFFF; + shared_mem_size = shared_mem_size.next_multiple_of(0x1000); swkbd.shared_memory_size = shared_mem_size;