Skip to content

Commit 408501b

Browse files
committed
---
yaml --- r: 11223 b: refs/heads/master c: 6408d54 h: refs/heads/master i: 11221: 7f94c9f 11219: 7990a2a 11215: 989f104 v: v3
1 parent ec9d4f1 commit 408501b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 005a3efb8bc8b21d19ddb72811ec95917ca74e27
2+
refs/heads/master: 6408d54c133554a938ffc304f320786cfe6a424e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export
1717
from_char,
1818
from_chars,
1919
from_cstr,
20+
from_cstr_len,
2021
concat,
2122
connect,
2223

@@ -210,6 +211,24 @@ unsafe fn from_cstr(cstr: sbuf) -> str {
210211
ret from_bytes(res);
211212
}
212213

214+
/*
215+
Function: from_cstr_len
216+
217+
Create a Rust string from a C string of the given length
218+
*/
219+
unsafe fn from_cstr_len(cstr: sbuf, len: uint) -> str {
220+
let res = [];
221+
let start = cstr;
222+
let curr = start;
223+
let i = 0u;
224+
while i < len {
225+
vec::push(res, *curr);
226+
i += 1u;
227+
curr = ptr::offset(start, i);
228+
}
229+
ret from_bytes(res);
230+
}
231+
213232
/*
214233
Function: concat
215234

0 commit comments

Comments
 (0)