mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Memory Leak
`dir` will leak memory if u use it with allocators that don´t care in freeing the memory at the end ( like arenas or the temp_allocator ) , because `strings.clone` and `strings.concatenate` are not using the passed allocator.
This commit is contained in:
@@ -284,13 +284,14 @@ rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (
|
|||||||
}
|
}
|
||||||
|
|
||||||
dir :: proc(path: string, allocator := context.allocator) -> string {
|
dir :: proc(path: string, allocator := context.allocator) -> string {
|
||||||
|
context.allocator = allocator
|
||||||
vol := volume_name(path)
|
vol := volume_name(path)
|
||||||
i := len(path) - 1
|
i := len(path) - 1
|
||||||
for i >= len(vol) && !is_separator(path[i]) {
|
for i >= len(vol) && !is_separator(path[i]) {
|
||||||
i -= 1
|
i -= 1
|
||||||
}
|
}
|
||||||
dir := clean(path[len(vol) : i+1], allocator)
|
dir := clean(path[len(vol) : i+1])
|
||||||
defer delete(dir, allocator)
|
defer delete(dir)
|
||||||
if dir == "." && len(vol) > 2 {
|
if dir == "." && len(vol) > 2 {
|
||||||
return strings.clone(vol)
|
return strings.clone(vol)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user