about summary refs log tree commit diff
path: root/src/lib
diff options
context:
space:
mode:
authorJoshua Wise <joshua@joshuawise.com>2011-11-25 02:42:56 -0500
committerNiko Matsakis <niko@alum.mit.edu>2011-11-28 10:41:45 -0800
commit45dc5356dfa37b80a3e5ed37783a38060fdb8c1f (patch)
tree12bde25809142db057e4532e74ff0665fe894b8b /src/lib
parentc2eb084b4c273682b06fcaf285399ec9bf6fd0cb (diff)
downloadrust-45dc5356dfa37b80a3e5ed37783a38060fdb8c1f.tar.gz
rust-45dc5356dfa37b80a3e5ed37783a38060fdb8c1f.zip
c_vec: Remove the mutable cast be forcing the pointer to be mutable throughout (discussion in #1217).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/c_vec.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/c_vec.rs b/src/lib/c_vec.rs
index 3b94c54f373..ff5f636d103 100644
--- a/src/lib/c_vec.rs
+++ b/src/lib/c_vec.rs
@@ -43,7 +43,7 @@ export ptr;
  */
 
 tag t<T> {
-    t({ base: *T, size: uint, rsrc: @dtor_res});
+    t({ base: *mutable T, size: uint, rsrc: @dtor_res});
 }
 
 resource dtor_res(dtor: option::t<fn@()>) {
@@ -57,14 +57,15 @@ resource dtor_res(dtor: option::t<fn@()>) {
  Section: Introduction forms
  */
 
-unsafe fn create<T>(base: *T, size: uint) -> t<T> {
+unsafe fn create<T>(base: *mutable T, size: uint) -> t<T> {
     ret t({base: base,
            size: size,
            rsrc: @dtor_res(option::none)
           });
 }
 
-unsafe fn create_with_dtor<T>(base: *T, size: uint, dtor: fn@()) -> t<T> {
+unsafe fn create_with_dtor<T>(base: *mutable T, size: uint, dtor: fn@())
+  -> t<T> {
     ret t({base: base,
            size: size,
            rsrc: @dtor_res(option::some(dtor))
@@ -77,12 +78,12 @@ unsafe fn create_with_dtor<T>(base: *T, size: uint, dtor: fn@()) -> t<T> {
 
 fn get<copy T>(t: t<T>, ofs: uint) -> T {
     assert ofs < (*t).size;
-    ret unsafe { *ptr::offset((*t).base, ofs) };
+    ret unsafe { *ptr::mut_offset((*t).base, ofs) };
 }
 
 fn set<copy T>(t: t<T>, ofs: uint, v: T) {
     assert ofs < (*t).size;
-    unsafe { *(ptr::offset((*t).base, ofs) as *mutable T) = v };
+    unsafe { *ptr::mut_offset((*t).base, ofs) = v };
 }
 
 /*
@@ -93,6 +94,6 @@ fn size<T>(t: t<T>) -> uint {
     ret (*t).size;
 }
 
-unsafe fn ptr<T>(t: t<T>) -> *T {
+unsafe fn ptr<T>(t: t<T>) -> *mutable T {
     ret (*t).base;
 }