refactor: Ignored allocation errors.

This commit is contained in:
2026-06-24 12:50:10 -04:00
parent 9256d94f70
commit 78984b57ff
3 changed files with 5 additions and 10 deletions

View File

@@ -20,7 +20,7 @@
10. **config.odin:178**`search_paths` silently ignores `os.user_home_dir` error. If home is empty, `~` isn't expanded. Same class of bug as issue 3.
12. **db.odin:352-353**`hex.encode` error ignored. `string(hex_bytes)` aliases the byte slice.
12. Consistently ignore allocator errors
13. **cmd_sync.odin:80, cmd_list.odin:33**`make([]string, 2)` for table rows never freed. Leaks per row. Defer to memory pass.

11
db.odin
View File

@@ -1,5 +1,6 @@
package main
import "base:runtime"
import "core:crypto/hash"
import "core:encoding/hex"
import "core:encoding/ini"
@@ -406,9 +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.allocator)
return EnvFile {
Path = abs_path,
Dir = dir,
@@ -453,11 +452,7 @@ db_sync :: proc(db: ^Db, f: ^EnvFile) -> (SyncFlag, SyncError) {
}
digest := hash.hash_bytes(hash.Algorithm.SHA256, data, context.temp_allocator)
hex_bytes, hex_err := hex.encode(digest, allocator)
if hex_err != nil {
fmt.eprintf("db_sync: failed to encode hash for %s: %v\n", f.Path, hex_err)
return result, .ReadFailed
}
hex_bytes := hex.encode(digest, allocator)
current_sha := string(hex_bytes)
if current_sha == f.Sha256 {

View File

@@ -436,7 +436,7 @@ test_db_sync_noop :: proc(t: ^testing.T) {
transmute([]u8)content,
context.temp_allocator,
)
hex_bytes, _ := hex.encode(digest, context.temp_allocator)
hex_bytes := hex.encode(digest, context.temp_allocator)
sha := string(hex_bytes)
db, ok := db_init()