mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
fix: Fixed leaks.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
3
db.odin
3
db.odin
@@ -407,7 +407,7 @@ new_env_file :: proc(path: string) -> (EnvFile, bool) {
|
||||
|
||||
digest := hash.hash_bytes(hash.Algorithm.SHA256, data, context.temp_allocator)
|
||||
// TODO: Handle error
|
||||
hex_bytes, _ := hex.encode(digest)
|
||||
hex_bytes, _ := hex.encode(digest, context.temp_allocator)
|
||||
|
||||
return EnvFile {
|
||||
Path = abs_path,
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user