Browse Source

Merge pull request #4266 from greenya/os-get-current-directory-allocator-arg

[core/os] get_current_directory: Add allocator arg to targets where i…
Laytan 11 months ago
parent
commit
0ca5e70c7d
5 changed files with 10 additions and 5 deletions
  1. 2 1
      core/os/os_darwin.odin
  2. 2 1
      core/os/os_freebsd.odin
  3. 2 1
      core/os/os_linux.odin
  4. 2 1
      core/os/os_netbsd.odin
  5. 2 1
      core/os/os_openbsd.odin

+ 2 - 1
core/os/os_darwin.odin

@@ -1095,7 +1095,8 @@ unset_env :: proc(key: string) -> Error {
 }
 
 @(require_results)
-get_current_directory :: proc() -> string {
+get_current_directory :: proc(allocator := context.allocator) -> string {
+	context.allocator = allocator
 	page_size := get_page_size() // NOTE(tetra): See note in os_linux.odin/get_current_directory.
 	buf := make([dynamic]u8, page_size)
 	for {

+ 2 - 1
core/os/os_freebsd.odin

@@ -840,7 +840,8 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string)
 }
 
 @(require_results)
-get_current_directory :: proc() -> string {
+get_current_directory :: proc(allocator := context.allocator) -> string {
+	context.allocator = allocator
 	// NOTE(tetra): I would use PATH_MAX here, but I was not able to find
 	// an authoritative value for it across all systems.
 	// The largest value I could find was 4096, so might as well use the page size.

+ 2 - 1
core/os/os_linux.odin

@@ -985,7 +985,8 @@ unset_env :: proc(key: string) -> Error {
 }
 
 @(require_results)
-get_current_directory :: proc() -> string {
+get_current_directory :: proc(allocator := context.allocator) -> string {
+	context.allocator = allocator
 	// NOTE(tetra): I would use PATH_MAX here, but I was not able to find
 	// an authoritative value for it across all systems.
 	// The largest value I could find was 4096, so might as well use the page size.

+ 2 - 1
core/os/os_netbsd.odin

@@ -894,7 +894,8 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string)
 }
 
 @(require_results)
-get_current_directory :: proc() -> string {
+get_current_directory :: proc(allocator := context.allocator) -> string {
+	context.allocator = allocator
 	// NOTE(tetra): I would use PATH_MAX here, but I was not able to find
 	// an authoritative value for it across all systems.
 	// The largest value I could find was 4096, so might as well use the page size.

+ 2 - 1
core/os/os_openbsd.odin

@@ -806,7 +806,8 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string)
 }
 
 @(require_results)
-get_current_directory :: proc() -> string {
+get_current_directory :: proc(allocator := context.allocator) -> string {
+	context.allocator = allocator
 	buf := make([dynamic]u8, MAX_PATH)
 	for {
 		cwd := _unix_getcwd(cstring(raw_data(buf)), c.size_t(len(buf)))