Fix comparison against nil for cstring

This commit is contained in:
gingerBill
2018-02-28 12:01:26 +00:00
parent 9da05dd4cb
commit 40542e6e26
2 changed files with 13 additions and 2 deletions
+5
View File
@@ -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;