Browse Source

harmonize to use null for c-string endings

Jon Lipstate 2 years ago
parent
commit
bbafc3fbd6
3 changed files with 3 additions and 3 deletions
  1. 1 1
      core/os/os2/path_linux.odin
  2. 1 1
      core/os/os_linux.odin
  3. 1 1
      core/strings/strings.odin

+ 1 - 1
core/os/os2/path_linux.odin

@@ -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)

+ 1 - 1
core/os/os_linux.odin

@@ -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)

+ 1 - 1
core/strings/strings.odin

@@ -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