1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use c_char;
use CStr;
use Utf8Error;
/// Creates a zeroed Vec with specified `capacity`.
///
/// # Safety
/// There is no guarantee that an all-zero byte-pattern represents a valid value of some type T.
///
/// From [std::mem::zeroed].
pub unsafe
/// Create a String using a string of null-terminated bytes `cstring`.
///
/// # Observation
/// All bytes are copied to the heap.
///
/// # Safety
/// * There is no guarantee to the validity of pointer.
/// * The returned lifetime is not guaranteed to be the actual lifetime of pointer.
/// * There is no guarantee that the memory pointed to by pointer contains a valid nul terminator byte
/// at the end of the string.
///
/// From [std::ffi::CStr::from_ptr].
///
pub unsafe