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;