mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix runtime.cstring_len
This commit is contained in:
@@ -348,12 +348,12 @@ string_le :: inline proc "contextless" (a, b: string) -> bool { return string_cm
|
|||||||
string_ge :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) >= 0; }
|
string_ge :: inline proc "contextless" (a, b: string) -> bool { return string_cmp(a, b) >= 0; }
|
||||||
|
|
||||||
cstring_len :: proc "contextless" (s: cstring) -> int {
|
cstring_len :: proc "contextless" (s: cstring) -> int {
|
||||||
n := 0;
|
p0 := uintptr((^byte)(s));
|
||||||
p := uintptr((^byte)(s));
|
p := p0;
|
||||||
for p != 0 && (^byte)(p)^ != 0 {
|
for p != 0 && (^byte)(p)^ != 0 {
|
||||||
p += 1;
|
p += 1;
|
||||||
}
|
}
|
||||||
return n;
|
return int(p - p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cstring_to_string :: proc "contextless" (s: cstring) -> string {
|
cstring_to_string :: proc "contextless" (s: cstring) -> string {
|
||||||
|
|||||||
Reference in New Issue
Block a user