Add additional assertions to rcl wrapper

This commit is contained in:
Tobias Stark 2024-10-08 13:03:52 +00:00 committed by Martin Dahl
parent a35d541378
commit 6311c2013f
1 changed files with 6 additions and 1 deletions

View File

@ -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).is_null());
let topic_name = unsafe { CStr::from_ptr(*n).to_str().unwrap().to_owned() };
assert!(!t.data.is_null());
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);