Skip to content

Commit

Permalink
Ensure name is null-terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
l0calh05t committed Jul 3, 2021
1 parent f246da3 commit c880556
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/auxiliary_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ fn go() -> Result<(), error::Error> {
user_data.tasks.push(BelaApp::create_auxiliary_task(
print_task,
10,
"printing_stuff",
&std::ffi::CString::new("printing_stuff").unwrap(),
));
user_data.tasks.push(BelaApp::create_auxiliary_task(
another_print_task,
10,
"printing_more_stuff",
&std::ffi::CStr::from_bytes_with_nul(b"printing_more_stuff\0").unwrap(),
));
Ok(())
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl<'a, T: UserData<'a> + 'a> Bela<T> {
pub fn create_auxiliary_task<Auxiliary>(
task: Box<Auxiliary>,
priority: i32,
name: &str,
name: &std::ffi::CStr,
) -> CreatedTask
where
Auxiliary: FnMut() + Send + 'static,
Expand All @@ -217,7 +217,7 @@ impl<'a, T: UserData<'a> + 'a> Bela<T> {
bela_sys::Bela_createAuxiliaryTask(
Some(auxiliary_task_trampoline::<Auxiliary>),
priority,
name.as_bytes().as_ptr(),
name.as_ptr(),
task_ptr,
)
};
Expand Down

0 comments on commit c880556

Please sign in to comment.