-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use `CStr` and `CString` instead, now that nightly has then in core and alloc, respectively. Fixes #336.
- Loading branch information
1 parent
67fb489
commit af05ed2
Showing
44 changed files
with
486 additions
and
2,306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,7 @@ | ||
//! Utilities related to FFI bindings. | ||
/// Minimal and unoptimized `strlen` implementation. | ||
/// | ||
/// TODO: Optimize this by reading a `usize` at a time. | ||
#[cfg(not(feature = "std"))] | ||
#[allow(unsafe_code)] | ||
unsafe fn strlen(mut s: *const u8) -> usize { | ||
let mut len = 0; | ||
while *s != b'\0' { | ||
len += 1; | ||
s = s.add(1); | ||
} | ||
len | ||
} | ||
|
||
#[cfg(not(feature = "std"))] | ||
mod z_str; | ||
|
||
#[cfg(not(feature = "std"))] | ||
pub use z_str::{FromBytesWithNulError, FromVecWithNulError, NulError, ZStr, ZString}; | ||
pub use core::ffi::{CStr, CString, FromBytesWithNulError, NulError}; | ||
|
||
#[cfg(feature = "std")] | ||
pub use std::ffi::{CStr as ZStr, CString as ZString, FromBytesWithNulError, NulError}; | ||
pub use std::ffi::{CStr, CString, FromBytesWithNulError, NulError}; |
Oops, something went wrong.