refactor: convert dep formula parser from DL lists to vec
Replace the 4 DL linked list structs in the dependency formula parser
(pkg_dep_formula, pkg_dep_formula_item, pkg_dep_version_item,
pkg_dep_option_item) with vec types stored inline.
Parser builds structs on the stack and pushes by value, transferring
ownership of inner vecs via shallow copy. This eliminates all per-element
heap allocations in the formula parser.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply at anthropic.com>
refactor: convert audit linked lists to vec, remove ref mechanism
Replace all linked lists in the audit system (pkg_audit_entry,
pkg_audit_package, pkg_audit_pkgname, pkg_audit_versions_range,
pkg_audit_cve) with vec types stored inline.
Remove the ref (reference entry) mechanism entirely. Instead of
creating lightweight copies that borrow pointers from the original
entry, the preprocess index now carries (entry, pkg_idx, name_idx)
triples to identify which package/name within an entry matched.
fix: handle trailing %% in printf format strings
Found by fuzz_printf: a format string ending with %% causes a
timeout because parse_format does not advance past the trailing
null byte. Add an early check in process_format_trailer() to
emit a literal %% and return when %% is the last character.
refactor: convert solver variable chain and rule items to slice/vec
Replace the solver variable DL chain with solve_var_slice_t — a simple
{begin, count} view into the flat variables array. Since variables for
the same UID are already allocated consecutively, no extra allocation
is needed beyond the slice struct itself.
Replace the rule items DL chain with vec_t(struct pkg_solve_item),
eliminating per-item heap allocations.
Remove the unused pkg_solve_impl_graph struct.
refactor: convert pkg->files from DL list + hash to sorted vec
Replace the doubly-linked list + pkghash (filehash) for package files
with a sorted vec_t(struct pkg_file) using bsearch for lookups.
refactor: convert request item DL chain to vec
Replace the doubly-linked list of pkg_job_request_item with
request_itemv_t (vec of inline items). This eliminates per-item heap
allocations and simplifies iteration/deletion in the solver and
upgrade chain processing.
fix: harden input validation found by fuzzing
- pkg_deps_parse_formula: handle empty/whitespace-only input gracefully
instead of asserting on NULL cur_item.name
- pkg_abi_from_string: handle empty version after ':' for wildcard ABI
(e.g. "*:") instead of asserting in pkg_abi_string_only_major_version
- pkg_addshlib_required: accept empty name gracefully instead of
asserting
fix: handle empty string in pkg_deps_parse_formula()
Found by fuzz_deps: passing an empty string triggers an assertion
failure at line 262 (cur_item != NULL in st_parse_comma state).
Add an early return for NULL or empty input.
refactor: replace universe item DL chain with vec
Replace the circular doubly-linked list of pkg_job_universe_item (keyed
by UID) with universe_itemv_t (vec of heap-allocated item pointers).
The pkghash maps uid -> universe_itemv_t * for O(1) lookup + indexed
access to all variants of a package.
This eliminates the prev/next/inhash fields, removes all circular
"rewind to head" patterns in the solver, and simplifies the double-nested
conflict traversals. Items remain heap-allocated for pointer stability
(request items and solver variables store item pointers).
libpkg: config: only assume repository enabled once
The current model means that one might have to track different
modifications that can be made to a repository in separate places, which
can be more challenging for, e.g., generated configuration. Implicit
enable makes a lot of sense in general, but it can be quite confusing
from a user-perspective that we'll enable a repository that was disabled
elsewhere when the overriding config is only specifying unrelated
things.
This is a potentially breaking change, but I think I'd be a little
surprised if anyone relies on this behavior in practice.
Closess #2671