Copies a UTF-8 string into memory and appends a trailing nul byte.
(&self, store: &mut Store, offset: usize, string: &str)
| 283 | |
| 284 | /// Copies a UTF-8 string into memory and appends a trailing nul byte. |
| 285 | pub fn write_cstring_bytes(&self, store: &mut Store, offset: usize, string: &str) -> Result<()> { |
| 286 | let mut bytes = Vec::with_capacity(string.len() + 1); |
| 287 | bytes.extend_from_slice(string.as_bytes()); |
| 288 | bytes.push(0); |
| 289 | self.copy_from_slice(store, offset, &bytes) |
| 290 | } |
| 291 | |
| 292 | /// Reads a C-style string from memory. |
| 293 | pub fn read_cstring(&self, store: &Store, offset: usize, len: usize) -> Result<CString> { |
no test coverage detected