about summary refs log tree commit diff
path: root/src/rt/rust.cpp
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-08-25 10:18:02 +0200
committerMarijn Haverbeke <marijnh@gmail.com>2011-08-29 09:07:53 +0200
commitc9c5ee252a8523778377f2832765442e611e85a4 (patch)
tree85c0837af34b2431fc17da0a166254144aaa99c7 /src/rt/rust.cpp
parent855e0a471365c7c61a139e2437215028bd231af5 (diff)
downloadrust-c9c5ee252a8523778377f2832765442e611e85a4.tar.gz
rust-c9c5ee252a8523778377f2832765442e611e85a4.zip
Implement non-internal ivecs
Vectors are now similar to our old, pre-internal vectors, except that
they are uniquely owned, not refcounted.

Their name should probably change too, then. I've renamed them to vec
in the runtime, will do so throughout the compiler later.
Diffstat (limited to 'src/rt/rust.cpp')
-rw-r--r--src/rt/rust.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index a158be04e57..b5a462154ed 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -10,7 +10,7 @@ command_line_args : public kernel_owned<command_line_args>
     rust_str **strs;
 
     // [str] passed to rust_task::start.
-    rust_ivec *args;
+    rust_vec *args;
 
     command_line_args(rust_task *task,
                       int sys_argc,
@@ -51,21 +51,13 @@ command_line_args : public kernel_owned<command_line_args>
             strs[i]->ref_count++;
         }
 
-        size_t ivec_interior_sz =
-            sizeof(size_t) * 2 + sizeof(rust_str *) * 4;
-        args = (rust_ivec *)
-            kernel->malloc(ivec_interior_sz,
+        args = (rust_vec *)
+            kernel->malloc(vec_size<rust_str*>(argc),
                            "command line arg interior");
-        args->fill = 0;
-        size_t ivec_exterior_sz = sizeof(rust_str *) * argc;
-        args->alloc = ivec_exterior_sz;
-        // NB: _rust_main owns the ivec payload and will be responsible for
+        args->fill = args->alloc = sizeof(rust_str *) * argc;
+        // NB: _rust_main owns the vec and will be responsible for
         // freeing it
-        args->payload.ptr = (rust_ivec_heap *)
-            kernel->malloc(ivec_exterior_sz + sizeof(size_t),
-                           "command line arg exterior");
-        args->payload.ptr->fill = ivec_exterior_sz;
-        memcpy(&args->payload.ptr->data, strs, ivec_exterior_sz);
+        memcpy(&args->data[0], strs, args->fill);
     }
 
     ~command_line_args() {