@@ -78,7 +78,7 @@ fn DtorRes(dtor: Option<@fn()>) -> DtorRes {
78
78
* * base - A foreign pointer to a buffer
79
79
* * len - The number of elements in the buffer
80
80
*/
81
- pub fn CVec < T > ( base : * mut T , len : uint ) -> CVec < T > {
81
+ pub unsafe fn CVec < T > ( base : * mut T , len : uint ) -> CVec < T > {
82
82
return CVec {
83
83
base : base,
84
84
len : len,
@@ -97,7 +97,7 @@ pub fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
97
97
* * dtor - A function to run when the value is destructed, useful
98
98
* for freeing the buffer, etc.
99
99
*/
100
- pub fn c_vec_with_dtor < T > ( base : * mut T , len : uint , dtor : @fn ( ) )
100
+ pub unsafe fn c_vec_with_dtor < T > ( base : * mut T , len : uint , dtor : @fn ( ) )
101
101
-> CVec < T > {
102
102
return CVec {
103
103
base : base,
@@ -138,7 +138,7 @@ pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) {
138
138
pub fn len < T > ( t : CVec < T > ) -> uint { t. len }
139
139
140
140
/// Returns a pointer to the first element of the vector
141
- pub fn ptr < T > ( t : CVec < T > ) -> * mut T { t. base }
141
+ pub unsafe fn ptr < T > ( t : CVec < T > ) -> * mut T { t. base }
142
142
143
143
#[ cfg( test) ]
144
144
mod tests {
@@ -191,7 +191,7 @@ mod tests {
191
191
#[ test]
192
192
fn test_and_I_mean_it ( ) {
193
193
let cv = malloc ( 16 u as size_t ) ;
194
- let p = ptr ( cv) ;
194
+ let p = unsafe { ptr ( cv) } ;
195
195
196
196
set ( cv, 0 u, 32u8 ) ;
197
197
set ( cv, 1 u, 33u8 ) ;
0 commit comments