Skip to content

Commit

Permalink
Merge pull request rust-lang#5 from bluss/libc-024
Browse files Browse the repository at this point in the history
Use memrchr definition from libc
  • Loading branch information
BurntSushi committed Dec 21, 2015
2 parents 62c2a51 + 4b10f07 commit 3cbe589
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license = "Unlicense/MIT"
name = "memchr"

[dependencies]
libc = "0.2"
libc = "0.2.4"

[dev-dependencies]
quickcheck = "0.2"
11 changes: 1 addition & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
// GNU's memrchr() will - unlike memchr() - error if haystack is empty.
if haystack.is_empty() {return None}
let p = unsafe {
ffi::memrchr(
libc::memrchr(
haystack.as_ptr() as *const c_void,
needle as c_int,
haystack.len() as size_t)
Expand Down Expand Up @@ -253,15 +253,6 @@ mod fallback {
}
}

#[cfg(target_os = "linux")]
mod ffi {
use libc::c_void;
use libc::{c_int, size_t};
extern {
pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
}
}

#[cfg(test)]
mod tests {
extern crate quickcheck;
Expand Down

0 comments on commit 3cbe589

Please sign in to comment.