Skip to content

Commit

Permalink
auto merge of #6339 : alexcrichton/rust/unsafe-cvec, r=catamorphism
Browse files Browse the repository at this point in the history
As noted by @jwise [here](5244512#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.
  • Loading branch information
bors committed May 10, 2013
2 parents ad8e236 + d6efbad commit 3e106cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/c_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3e106cf

Please sign in to comment.