blob: 32ad60ff84273bf1f1af2a03878966b3067aa27b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
//! C-string utilities
pub fn len(str: [*:0]const u8) usize {
var i: usize = 0;
while (str[i] != 0) : (i += 1) {}
return i;
}
pub fn toSlice(str: [*:0]const u8) []const u8 {
return str[0..len(str)];
}
pub fn findNull(buf: []const u8) usize {
var i: usize = 0;
while (i < buf.len and buf[i] != 0) : (i += 1) {}
return i;
}
|