diff options
author | Isis Lovecruft <isis@torproject.org> | 2018-02-08 22:08:11 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2018-02-10 02:15:06 +0000 |
commit | 3c4e006e7e9597ef0d478ef63c811c764926bfbe (patch) | |
tree | 35a96e5fe802960d9b879308e215b7fc86921bab /src/rust/protover/ffi.rs | |
parent | 8fff331bb095dc6f5e2fe2ecfc9ab08ea9e2fe97 (diff) | |
download | tor-3c4e006e7e9597ef0d478ef63c811c764926bfbe.tar.gz tor-3c4e006e7e9597ef0d478ef63c811c764926bfbe.zip |
rust: Use tor_util::strings utils for protover_get_supported_protocols.
Diffstat (limited to 'src/rust/protover/ffi.rs')
-rw-r--r-- | src/rust/protover/ffi.rs | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index 2ee0286ecf..404b158388 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -15,7 +15,6 @@ use tor_allocate::allocate_and_copy_string; use tor_util::strings::byte_slice_is_c_like; use tor_util::strings::empty_static_cstr; - /// Translate C enums to Rust Proto enums, using the integer value of the C /// enum to map to its associated Rust enum /// @@ -143,18 +142,7 @@ pub extern "C" fn protocol_list_supports_protocol_or_later( pub extern "C" fn protover_get_supported_protocols() -> *const c_char { let supported: &'static CStr; - // If we're going to pass it to C, there cannot be any intermediate NUL - // bytes. An assert is okay here, since changing the const byte slice - // in protover.rs to contain a NUL byte somewhere in the middle would be a - // programming error. - assert!(byte_slice_is_c_like(SUPPORTED_PROTOCOLS)); - - // It's okay to unwrap the result of this function because - // we can see that the bytes we're passing into it 1) are valid UTF-8, - // 2) have no intermediate NUL bytes, and 3) are terminated with a NUL - // byte. - supported = CStr::from_bytes_with_nul(SUPPORTED_PROTOCOLS).unwrap(); - + supported = get_supported_protocols_cstr(); supported.as_ptr() } |