diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-08-25 10:18:02 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-08-29 09:07:53 +0200 |
| commit | c9c5ee252a8523778377f2832765442e611e85a4 (patch) | |
| tree | 85c0837af34b2431fc17da0a166254144aaa99c7 /src/rt/rust_util.h | |
| parent | 855e0a471365c7c61a139e2437215028bd231af5 (diff) | |
| download | rust-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_util.h')
| -rw-r--r-- | src/rt/rust_util.h | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/rt/rust_util.h b/src/rt/rust_util.h index 6ab7d305a82..10cdbce6109 100644 --- a/src/rt/rust_util.h +++ b/src/rt/rust_util.h @@ -197,28 +197,18 @@ typedef rust_evec rust_str; // Interior vectors (rust-user-code level). struct -rust_ivec_heap -{ - size_t fill; - uint8_t data[]; -}; - -// Note that the payload is actually size 4*sizeof(elem), even when heapified -union -rust_ivec_payload -{ - rust_ivec_heap *ptr; // if on heap - uint8_t data[]; // if on stack -}; - -struct -rust_ivec +rust_vec { size_t fill; // in bytes; if zero, heapified size_t alloc; // in bytes - rust_ivec_payload payload; + uint8_t data[0]; }; +template <typename T> +inline size_t vec_size(size_t elems) { + return sizeof(rust_vec) + sizeof(T) * elems; +} + // // Local Variables: // mode: C++ |
