Before the text that was passed to button_create was simply passed as a pointer to the data struct, making it the caller's responsibility to keep the string alive for as long as the component is alive.
The comments in ui.rs were incorrect:
bitbox02_sys::trinary_choice_create(
crate::util::str_to_cstr_vec(message).unwrap().as_ptr(), // copied in C
crate::util::str_to_cstr_vec(label_left).unwrap().as_ptr(), // copied in C
crate::util::str_to_cstr_vec(label_middle).unwrap().as_ptr(), // copied in C
crate::util::str_to_cstr_vec(label_right).unwrap().as_ptr(), // copied in C
...
Since the three labels are buttons, the text was not copied and the pointer becomes dangling.
I checked all instances and found that all button label strings are
short and fit in 20 bytes. A lower number here is better to save
binary space. Can increase it in the future if needed.
Before the text that was passed to button_create was simply passed as a pointer to the data struct, making it the caller's responsibility to keep the string alive for as long as the component is alive.
The comments in ui.rs were incorrect:
Since the three labels are buttons, the text was not copied and the pointer becomes dangling.
I checked all instances and found that all button label strings are short and fit in 20 bytes. A lower number here is better to save binary space. Can increase it in the future if needed.