Skip to content

Commit 0b448d8

Browse files
committed
---
yaml --- r: 3778 b: refs/heads/master c: 875c462 h: refs/heads/master v: v3
1 parent 04b929b commit 0b448d8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 91dcc1d054cdf86582bad6b6d343761041a1f5de
2+
refs/heads/master: 875c4622fba068149a9c635684c644d84cb3e014

trunk/src/lib/ivec.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,11 @@ mod unsafe {
207207
fn copy_from_buf[T](&mutable T[] v, *T ptr, uint count) {
208208
ret rustrt::ivec_copy_from_buf_shared(v, ptr, count);
209209
}
210+
211+
fn from_buf[T](*T ptr, uint bytes) -> T[] {
212+
auto v = ~[];
213+
copy_from_buf(v, ptr, bytes);
214+
ret v;
215+
}
210216
}
211217

trunk/src/lib/str.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export connect;
4848
export connect_ivec;
4949
export to_upper;
5050
export safe_slice;
51+
export bytes_ivec;
5152

5253
native "rust" mod rustrt {
5354
type sbuf;
@@ -163,6 +164,12 @@ fn buf(str s) -> sbuf { ret rustrt::str_buf(s); }
163164

164165
fn bytes(str s) -> vec[u8] { ret rustrt::str_vec(s); }
165166

167+
fn bytes_ivec(str s) -> u8[] {
168+
auto sbuffer = buf(s);
169+
auto ptr = unsafe::reinterpret_cast(sbuffer);
170+
ret ivec::unsafe::from_buf(ptr, byte_len(s));
171+
}
172+
166173
fn from_bytes(vec[u8] v) -> str { ret rustrt::str_from_vec(v); }
167174

168175

0 commit comments

Comments
 (0)