-
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.
* Remove `ZStr` and `ZString`. Use `CStr` and `CString` instead, now that nightly has then in core and alloc, respectively. Fixes #336. * Enable "core_c_str" on nightly to use core::ffi::CStr. * Don't test --no-default-features on stable. --no-default-features disables "std", and building without "std" will require nightly now. * `CString` and `NulError` are in alloc. * Add comments to the relevant Cargo.toml features. * rustfmt
- Loading branch information
1 parent
ea0f3b0
commit b437157
Showing
46 changed files
with
497 additions
and
2,308 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
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,9 @@ | ||
//! 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; | ||
|
||
pub use alloc::ffi::{CString, NulError}; | ||
#[cfg(not(feature = "std"))] | ||
pub use z_str::{FromBytesWithNulError, FromVecWithNulError, NulError, ZStr, ZString}; | ||
pub use core::ffi::{CStr, FromBytesWithNulError}; | ||
|
||
#[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.