harmonize to use null for c-string endings

This commit is contained in:
Jon Lipstate
2023-03-28 11:57:12 -07:00
parent 194fa7cd98
commit bbafc3fbd6
3 changed files with 3 additions and 3 deletions

View File

@@ -211,7 +211,7 @@ _getwd :: proc(allocator: runtime.Allocator) -> (string, Error) {
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
if res >= 0 {
return strings.string_from_zero_terminated_ptr(&buf[0], len(buf)), nil
return strings.string_from_null_terminated_ptr(&buf[0], len(buf)), nil
}
if res != -ERANGE {
return "", _get_platform_error(res)

View File

@@ -913,7 +913,7 @@ get_current_directory :: proc() -> string {
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
if res >= 0 {
return strings.string_from_zero_terminated_ptr(&buf[0], len(buf))
return strings.string_from_null_terminated_ptr(&buf[0], len(buf))
}
if _get_errno(res) != ERANGE {
delete(buf)

View File

@@ -86,7 +86,7 @@ NOTE: The created string is only valid as long as the pointer and length are val
**Returns** A string created from the null-terminated byte pointer and length
*/
string_from_zero_terminated_ptr :: proc(ptr: ^byte, len: int) -> string {
string_from_null_terminated_ptr :: proc(ptr: ^byte, len: int) -> string {
s := transmute(string)mem.Raw_String{ptr, len}
s = truncate_to_byte(s, 0)
return s