File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 91dcc1d054cdf86582bad6b6d343761041a1f5de
2
+ refs/heads/master: 875c4622fba068149a9c635684c644d84cb3e014
Original file line number Diff line number Diff line change @@ -207,5 +207,11 @@ mod unsafe {
207
207
fn copy_from_buf[ T ] ( & mutable T [ ] v, * T ptr, uint count) {
208
208
ret rustrt:: ivec_copy_from_buf_shared( v, ptr, count) ;
209
209
}
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
+ }
210
216
}
211
217
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ export connect;
48
48
export connect_ivec;
49
49
export to_upper;
50
50
export safe_slice;
51
+ export bytes_ivec;
51
52
52
53
native "rust" mod rustrt {
53
54
type sbuf ;
@@ -163,6 +164,12 @@ fn buf(str s) -> sbuf { ret rustrt::str_buf(s); }
163
164
164
165
fn bytes ( str s) -> vec[ u8 ] { ret rustrt:: str_vec ( s) ; }
165
166
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
+
166
173
fn from_bytes ( vec[ u8] v ) -> str { ret rustrt:: str_from_vec ( v) ; }
167
174
168
175
You can’t perform that action at this time.
0 commit comments