diff options
| author | Bobby <[email protected]> | 2026-02-15 21:44:15 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-02-15 21:44:15 +0530 |
| commit | 85ea61c58c96b5ae052e40fce777f8e3d2b7ca62 (patch) | |
| tree | ab7e84dd64e8600d6c102ed12a8f598962b88aff /system/libraries/string/cstring.zig | |
| parent | 71e5250b05d06505612dc5a0fcf3d25fb5277cf5 (diff) | |
| download | akiba-85ea61c58c96b5ae052e40fce777f8e3d2b7ca62.tar.xz akiba-85ea61c58c96b5ae052e40fce777f8e3d2b7ca62.zip | |
feat: Add core libraries for color, formatting, I/O, string manipulation, and memory utilities
Diffstat (limited to 'system/libraries/string/cstring.zig')
| -rw-r--r-- | system/libraries/string/cstring.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/system/libraries/string/cstring.zig b/system/libraries/string/cstring.zig new file mode 100644 index 0000000..32ad60f --- /dev/null +++ b/system/libraries/string/cstring.zig @@ -0,0 +1,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; +} |
