Skip to content

Commit

Permalink
Add additional assertions to rcl wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstarkwayve committed Oct 8, 2024
1 parent 89cec03 commit 00bd39e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion r2r/src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,12 +1239,17 @@ impl Node {
let types = unsafe { std::slice::from_raw_parts(tnat.types, tnat.names.size) };

for (n, t) in names.iter().zip(types) {
assert!(*n != std::ptr::null_mut());
let topic_name = unsafe { CStr::from_ptr(*n).to_str().unwrap().to_owned() };
assert!(t != std::ptr::null_mut());
let topic_types = unsafe { std::slice::from_raw_parts(t, t.size) };
let topic_types: Vec<String> = unsafe {
topic_types
.iter()
.map(|t| CStr::from_ptr(*(t.data)).to_str().unwrap().to_owned())
.map(|t| {
assert!(*(t.data) != std::ptr::null_mut());
CStr::from_ptr(*(t.data)).to_str().unwrap().to_owned()
})
.collect()
};
res.insert(topic_name, topic_types);
Expand Down

0 comments on commit 00bd39e

Please sign in to comment.