Debian Codegraph @

third_party/rust/cubeb-core/src/util.rs

raw
1 // Copyright © 2017 Mozilla Foundation
2 //
3 // This program is made available under an ISC-style license. See the
4 // accompanying file LICENSE for details.
5
6 use std::ffi::CStr;
7 use std::os::raw::c_char;
8
9 pub unsafe fn opt_bytes<'a>(c: *const c_char) -> Option<&'a [u8]> {
10 if c.is_null() {
11 None
12 } else {
13 Some(CStr::from_ptr(c).to_bytes())
14 }
15 }