mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 14:18:47 +00:00
Fix comparison against nil for cstring
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import "core:mem.odin"
|
||||
import "core:raw.odin"
|
||||
|
||||
new_string :: proc(s: string) -> string {
|
||||
c := make([]byte, len(s)+1);
|
||||
@@ -19,6 +20,10 @@ to_odin_string :: proc(str: cstring) -> string {
|
||||
return string(str);
|
||||
}
|
||||
|
||||
string_from_ptr :: proc(ptr: ^byte, len: int) -> string {
|
||||
return transmute(string)raw.String{ptr, len};
|
||||
}
|
||||
|
||||
contains_rune :: proc(s: string, r: rune) -> int {
|
||||
for c, offset in s {
|
||||
if c == r do return offset;
|
||||
|
||||
Reference in New Issue
Block a user