[PATCH v2 01/12] diff-delta: widen `struct delta_index`' size fields to `size_t`
"Johannes Schindelin via GitGitGadget" <[email protected]> Wed, 05 Aug 2026 16:14:28 +0000
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <0012c1007bc5d0e6ab143a0ab8201456e4f33a24.1785946479.git.gitgitgadget@gmail.com> |
From: Johannes Schindelin <[email protected]> Preparation for widening the delta-encoding API to `size_t` in subsequent commits, which is what lets pack-objects drop the `cast_size_t_to_ulong()` shims that 606c192380 (odb, packfile: use size_t for streaming object sizes, 2026-05-08) had to leave behind in `get_delta()` and `try_delta()` because their downstream consumers were still narrow. The struct is private to diff-delta.c, so widening its fields in isolation is a no-op at runtime: the values stored continue to fit in 32 bits on Windows because the public API around it still truncates. Splitting it out keeps the API-change commit focused on caller updates. Since the `memsize` attribute is returned by the `sizeof_delta_index()` function verbatim, that function's return type is adjusted, too. Assisted-by: Opus 4.7 Helped-by: Patrick Steinhardt <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> --- delta.h | 2 +- diff-delta.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/delta.h b/delta.h index eb5c6d2fdb..ab0279168c 100644 --- a/delta.h +++ b/delta.h @@ -28,7 +28,7 @@ void free_delta_index(struct delta_index *index); * * Given pointer must be what create_delta_index() returned, or NULL. */ -unsigned long sizeof_delta_index(struct delta_index *index); +size_t sizeof_delta_index(struct delta_index *index); /* * create_delta: create a delta from given index for the given buffer diff --git a/diff-delta.c b/diff-delta.c index 43c339f010..9e1f9e6f95 100644 --- a/diff-delta.c +++ b/diff-delta.c @@ -125,9 +125,9 @@ struct unpacked_index_entry { }; struct delta_index { - unsigned long memsize; + size_t memsize; const void *src_buf; - unsigned long src_size; + size_t src_size; unsigned int hash_mask; struct index_entry *hash[FLEX_ARRAY]; }; @@ -140,7 +140,7 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) struct unpacked_index_entry *entry, **hash; struct index_entry *packed_entry, **packed_hash; void *mem; - unsigned long memsize; + size_t memsize; if (!buf || !bufsize) return NULL; @@ -302,7 +302,7 @@ void free_delta_index(struct delta_index *index) free(index); } -unsigned long sizeof_delta_index(struct delta_index *index) +size_t sizeof_delta_index(struct delta_index *index) { if (index) return index->memsize; -- gitgitgadget