diff options
| author | bors <bors@rust-lang.org> | 2013-05-09 23:58:53 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-05-09 23:58:53 -0700 |
| commit | 3e106cf2c2556be6bbcd9a93e5ef2a73b98f0e7a (patch) | |
| tree | 5fa1b7e055936837095f993c2db6341f8f2565e1 /src/libstd | |
| parent | ad8e236f32fccf6ec99025e2ba77f79b4c98d399 (diff) | |
| parent | d6efbad33fc4e75df77c4f90ef83e3a0da0e0bb5 (diff) | |
| download | rust-3e106cf2c2556be6bbcd9a93e5ef2a73b98f0e7a.tar.gz rust-3e106cf2c2556be6bbcd9a93e5ef2a73b98f0e7a.zip | |
auto merge of #6339 : alexcrichton/rust/unsafe-cvec, r=catamorphism
As noted by @jwise [here](https://github.com/mozilla/rust/commit/52445129fdb4ee847332acbf516ced8f73b7990a#commitcomment-3172192), it's probably a good idea to keep these unsafe. The lint check won't warn about these because it ignore `unsafe fn` declarations.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/c_vec.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index b4b4e2bf1a2..17b7bae6de5 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -78,7 +78,7 @@ fn DtorRes(dtor: Option<@fn()>) -> DtorRes { * * base - A foreign pointer to a buffer * * len - The number of elements in the buffer */ -pub fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { +pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { return CVec{ base: base, len: len, @@ -97,7 +97,7 @@ pub fn CVec<T>(base: *mut T, len: uint) -> CVec<T> { * * dtor - A function to run when the value is destructed, useful * for freeing the buffer, etc. */ -pub fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn()) +pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn()) -> CVec<T> { return CVec{ base: base, @@ -138,7 +138,7 @@ pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) { pub fn len<T>(t: CVec<T>) -> uint { t.len } /// Returns a pointer to the first element of the vector -pub fn ptr<T>(t: CVec<T>) -> *mut T { t.base } +pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T { t.base } #[cfg(test)] mod tests { @@ -191,7 +191,7 @@ mod tests { #[test] fn test_and_I_mean_it() { let cv = malloc(16u as size_t); - let p = ptr(cv); + let p = unsafe { ptr(cv) }; set(cv, 0u, 32u8); set(cv, 1u, 33u8); |
