mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
os2: fix leak and always close directory
This commit is contained in:
@@ -76,7 +76,7 @@ concatenate :: proc(strings: []string, allocator: runtime.Allocator) -> (res: st
|
|||||||
for s in strings {
|
for s in strings {
|
||||||
n += len(s)
|
n += len(s)
|
||||||
}
|
}
|
||||||
buf := make([]byte, n) or_return
|
buf := make([]byte, n, allocator) or_return
|
||||||
n = 0
|
n = 0
|
||||||
for s in strings {
|
for s in strings {
|
||||||
n += copy(buf[n:], s)
|
n += copy(buf[n:], s)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ _remove_all :: proc(path: string) -> Error {
|
|||||||
if dir == nil {
|
if dir == nil {
|
||||||
return _get_platform_error()
|
return _get_platform_error()
|
||||||
}
|
}
|
||||||
|
defer posix.closedir(dir)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
posix.set_errno(.NONE)
|
posix.set_errno(.NONE)
|
||||||
@@ -91,7 +92,6 @@ _remove_all :: proc(path: string) -> Error {
|
|||||||
if posix.rmdir(cpath) != .OK {
|
if posix.rmdir(cpath) != .OK {
|
||||||
return _get_platform_error()
|
return _get_platform_error()
|
||||||
}
|
}
|
||||||
posix.closedir(dir)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user