Open starlitxiling opened 4 days ago
if you want to reproduce my problem, you can refer this:https://github.com/dora-rs/autoware.universe/tree/feature/autoware_dora/tools/read_id_test
Because String
does not contain \0
char (nul terminator) which is very different from C-string.
You can push a '\0' at this line to see how these been changed. https://github.com/dora-rs/dora/blob/01c404710bd77b758c20ac179ca6e0a3d6705324/libraries/core/src/config.rs#L86-L90
impl From<String> for DataId {
fn from(id: String) -> Self {
let mut id = id;
id.push('\0');
Self(id)
}
}
by the way, please use strncmp
for possibly null-terminator string instead of strcmp
impl From<String> for DataId {
fn from(id: String) -> Self {
let mut id = id;
id.push('\0');
Self(id)
}
}
I tried this, but it fails when parsing dataflow.yml. I think pushing 0 directly will cause many problems.
Or learn from https://github.com/eclipse-zenoh/zenoh-c/blob/775e66586d105cbb42882ace58286f0cb2d967b2/src/commons.rs#L551-L568
I thing that let user release id-string is error-prone.
When I use the C API, I find that some unpredictable id appear in read_dora_input_id, and it will be the same string I create after that. If I don't create it after that, it will be a segment of id plus a strange hexadecimal number (like BCAG). I think there is a pointer error phenomenon. I don't know if this is related to #540![12ff8c64e23d5bbef8f51c26de7bd50](https://github.com/dora-rs/dora/assets/62335818/7492b53f-62be-4927-9bc3-bfe1db5f2042)