[PATCH v2 05/12] pack-objects: widen `mem_usage` and `try_delta()`'s out-param to `size_t`
"Johannes Schindelin via GitGitGadget" <[email protected]> Wed, 05 Aug 2026 16:14:32 +0000
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <c3019582844896d026a092c356b3b1b0e99e3fa8.1785946479.git.gitgitgadget@gmail.com> |
From: Johannes Schindelin <[email protected]> The pair must move together because `find_deltas()` passes `&mem_usage` to `try_delta()`: widening either alone breaks the type match. `mem_usage` accumulates per-object byte counts already computed in `size_t` (`SIZE()` and `sizeof_delta_index()` reach here through `free_unpacked()`, now `size_t`), and was the last 32-bit-on-Windows narrowing point in the delta-window memory accounting chain. With this commit, that chain uses `size_t` consistently except for `sizeof_delta_index()`'s still-narrow return, whose value is bounded by `create_delta_index()`'s entries cap. `window_memory_limit` (config-driven via `git_config_ulong()`) stays `unsigned long`: it is only compared against `mem_usage` and promotes. Assisted-by: Opus 4.7 Signed-off-by: Johannes Schindelin <[email protected]> --- builtin/pack-objects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 503ebbf091..96ecee393e 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2804,7 +2804,7 @@ size_t oe_get_size_slow(struct packing_data *pack, } static int try_delta(struct unpacked *trg, struct unpacked *src, - unsigned max_depth, unsigned long *mem_usage) + unsigned max_depth, size_t *mem_usage) { struct object_entry *trg_entry = trg->entry; struct object_entry *src_entry = src->entry; @@ -2991,7 +2991,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, { uint32_t i, idx = 0, count = 0; struct unpacked *array; - unsigned long mem_usage = 0; + size_t mem_usage = 0; CALLOC_ARRAY(array, window); -- gitgitgadget