diff --git a/cmd_check.odin b/cmd_check.odin index e59b6d8..a90bf71 100644 --- a/cmd_check.odin +++ b/cmd_check.odin @@ -4,6 +4,8 @@ import "core:fmt" import "core:os" import "core:path/filepath" +// TODO: What happens if you pass a non existent path to cmd_check? +// TODO: UX could be improved, so "run envr add ." if file not exists. cmd_check :: proc(cmd: ^Command) { check_path: string if len(cmd.args) > 0 { @@ -37,7 +39,8 @@ cmd_check :: proc(cmd: ^Command) { is_dir := os.is_directory(abs_path) - files_in_path: [dynamic]string + // TODO: set a reasonable default + files_in_path := make([dynamic]string, context.temp_allocator) if is_dir { scanned, scan_ok := scan_path(abs_path, db.cfg) diff --git a/cmd_scan.odin b/cmd_scan.odin index b0f03f1..3a4d4c7 100644 --- a/cmd_scan.odin +++ b/cmd_scan.odin @@ -23,9 +23,15 @@ cmd_scan :: proc(cmd: ^Command) { } // TODO: Figure out a sane default - all_files: [dynamic]string + // Can't use temp allocator becuase strings inside are copied to context.allocator + all_files := make([dynamic]string) + defer { + for &f in all_files {delete(f)} + delete(all_files) + } for dir in search_dirs { found, scan_ok := scan_path(dir, db.cfg) + defer delete(found) if !scan_ok { fmt.wprintf(cmd.err, "Error scanning %s\n", dir, flush = false) continue diff --git a/cmd_sync.odin b/cmd_sync.odin index 2cd78b7..8239101 100644 --- a/cmd_sync.odin +++ b/cmd_sync.odin @@ -25,7 +25,15 @@ cmd_sync :: proc(cmd: ^Command) { return } - results := make([]SyncEntry, len(files), context.temp_allocator) + // TODO: Can't use temp allocator becuase strings inside are copied to context.allocator + results := make([]SyncEntry, len(files)) + defer { + for &e in results { + delete(e.Path) + delete(e.Status) + } + delete(results) + } for &file, i in files { result, err := db_sync(&db, &file) diff --git a/db.odin b/db.odin index 1c6d68c..192ecd7 100644 --- a/db.odin +++ b/db.odin @@ -550,6 +550,7 @@ get_git_remotes :: proc(dir: string, allocator: mem.Allocator) -> [dynamic]strin if r == url {found = true; break} } if !found { + // FIXME: Currently leaks when adding a file with envr scan cloned, _ := strings.clone(url, allocator) append(&remotes, cloned) }