style: Ignored allocation errors where possible.

This commit is contained in:
2026-06-25 17:27:26 -04:00
parent 13e9495642
commit 6fa68d10b1
5 changed files with 17 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
# TODOs # TODOs
1. Commands are still leaking. (Do 13. first) 1. Commands are still leaking. (Write tests for everything first)
2. Add color flag and support non colored output. 2. Add color flag and support non colored output.
@@ -8,27 +8,25 @@
4. Generate md and man pages again. 4. Generate md and man pages again.
5. Consistently ignore allocator errors 5. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`.
6. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`. 6. Add a text filter to the multi_select.
7. Add a text filter to the multi_select. 7. Add tests for untested commands.
8. Add tests for untested commands. 8. add --format -f flag to commands that draw tables.
9. add --format -f flag to commands that draw tables. 9. procedures should be ordered by use, main at the top, then in the order they are called from main.
10. procedures should be ordered by use, main at the top, then in the order they are called from main. 10. Shell completion
11. Shell completion 11. Bring back windows support / cross-compilation.
12. Bring back windows support / cross-compilation. 12. Test all cmds / terminal branches.
13. Test all cmds / terminal branches. 13. Pass allocator to findr?
14. Pass allocator to findr? 14. Update `read_wire_string` to use a slice.
15. Update `read_wire_string` to use a slice.
## Double-check AI output ## Double-check AI output

View File

@@ -123,7 +123,7 @@ new_config :: proc(
for priv in private_key_paths { for priv in private_key_paths {
// TODO: Is this bad? // TODO: Is this bad?
priv_key := strings.clone(priv) priv_key := strings.clone(priv)
pub, _ := strings.concatenate([]string{priv_key, ".pub"}) pub := strings.concatenate([]string{priv_key, ".pub"})
append(&keys, SshKeyPair{private = priv_key, public = pub}) append(&keys, SshKeyPair{private = priv_key, public = pub})
} }

View File

@@ -572,7 +572,7 @@ try_move_dir :: proc(db: ^Db, f: ^EnvFile, allocator: mem.Allocator) -> (bool, S
case 0: case 0:
return false, .DirMissing return false, .DirMissing
case 1: case 1:
f.dir, _ = strings.clone(matched_dir, allocator) f.dir = strings.clone(matched_dir, allocator)
base := filepath.base(f.path) base := filepath.base(f.path)
new_path, _ := filepath.join({f.dir, base}, allocator) new_path, _ := filepath.join({f.dir, base}, allocator)
f.path = new_path f.path = new_path
@@ -613,7 +613,7 @@ get_git_remotes :: proc(dir: string, allocator: mem.Allocator) -> [dynamic]strin
} }
if !found { if !found {
// FIXME: Currently leaks when adding a file with envr scan // FIXME: Currently leaks when adding a file with envr scan
cloned, _ := strings.clone(url, allocator) cloned := strings.clone(url, allocator)
append(&remotes, cloned) append(&remotes, cloned)
} }
} }

View File

@@ -26,7 +26,7 @@ find_repos :: proc(roots: []string, results: ^[dynamic]string, thread_count: int
pool.threads = make([]^thread.Thread, thread_count) pool.threads = make([]^thread.Thread, thread_count)
for root in roots { for root in roots {
root_clone, _ := strings.clone(root) root_clone := strings.clone(root)
append(&pool.queue, root_clone) append(&pool.queue, root_clone)
sync.atomic_sema_post(&pool.queue_sema) sync.atomic_sema_post(&pool.queue_sema)
} }
@@ -97,7 +97,7 @@ process_repo_dir :: proc(pool: ^RepoPool, dir_path: string) {
defer linux.close(fd) defer linux.close(fd)
if has_git_dir(fd) { if has_git_dir(fd) {
cloned, _ := strings.clone(dir_path) cloned := strings.clone(dir_path)
sync.mutex_lock(&pool.results_lock) sync.mutex_lock(&pool.results_lock)
append(pool.results, cloned) append(pool.results, cloned)
sync.mutex_unlock(&pool.results_lock) sync.mutex_unlock(&pool.results_lock)

View File

@@ -137,7 +137,7 @@ collect_results :: proc(env: TestEnv, args: []string, opts: WalkOptions) -> [dyn
if len(stripped) > 0 && stripped[0] == os.Path_Separator { if len(stripped) > 0 && stripped[0] == os.Path_Separator {
stripped = stripped[1:] stripped = stripped[1:]
} }
new_r, _ := strings.clone(stripped) new_r := strings.clone(stripped)
delete(r) delete(r)
results[i] = new_r results[i] = new_r
} }