stepflow_wasm/
cstr.rs

1#[macro_export]
2macro_rules! str_from_cstr {
3  ($cstr_ptr:ident) => {
4      {
5          let s: &str;
6          unsafe {
7              let data = CStr::from_ptr($cstr_ptr);
8              s = data.to_str().unwrap();
9          }
10          s
11      }
12  }
13}
14
15#[macro_export]
16macro_rules! str_from_cstr_or_null {
17  ($cstr_ptr:ident) => {
18      {
19          if $cstr_ptr.is_null() {
20              None
21          } else {
22              Some(str_from_cstr!($cstr_ptr))
23          }
24      }
25  };
26}