mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
harmonize to use null for c-string endings
This commit is contained in:
@@ -211,7 +211,7 @@ _getwd :: proc(allocator: runtime.Allocator) -> (string, Error) {
|
|||||||
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
|
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
|
||||||
|
|
||||||
if res >= 0 {
|
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 {
|
if res != -ERANGE {
|
||||||
return "", _get_platform_error(res)
|
return "", _get_platform_error(res)
|
||||||
|
|||||||
@@ -913,7 +913,7 @@ get_current_directory :: proc() -> string {
|
|||||||
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
|
#no_bounds_check res := unix.sys_getcwd(&buf[0], uint(len(buf)))
|
||||||
|
|
||||||
if res >= 0 {
|
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 {
|
if _get_errno(res) != ERANGE {
|
||||||
delete(buf)
|
delete(buf)
|
||||||
|
|||||||
@@ -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
|
**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 := transmute(string)mem.Raw_String{ptr, len}
|
||||||
s = truncate_to_byte(s, 0)
|
s = truncate_to_byte(s, 0)
|
||||||
return s
|
return s
|
||||||
|
|||||||
Reference in New Issue
Block a user