make use of the large object counter inside the packidx structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/libexec/got-index-pack/got-index-pack.c b/libexec/got-index-pack/got-index-pack.c
index 5086b21..580ee43 100644
--- a/libexec/got-index-pack/got-index-pack.c
+++ b/libexec/got-index-pack/got-index-pack.c
@@ -367,7 +367,7 @@ print_packidx(struct got_packidx *packidx)
#endif
static void
-update_packidx(int *nlarge, struct got_packidx *packidx, int nobj,
+update_packidx(struct got_packidx *packidx, int nobj,
struct got_indexed_object *obj)
{
int i, n, idx;
@@ -391,10 +391,11 @@ update_packidx(int *nlarge, struct got_packidx *packidx, int nobj,
if (obj->off < GOT_PACKIDX_OFFSET_VAL_IS_LARGE_IDX)
packidx->hdr.offsets[idx] = htobe32(obj->off);
else {
- packidx->hdr.offsets[idx] = htobe32(*nlarge |
+ packidx->hdr.offsets[idx] = htobe32(packidx->nlargeobj |
GOT_PACKIDX_OFFSET_VAL_IS_LARGE_IDX);
- packidx->hdr.large_offsets[*nlarge] = htobe64(obj->off);
- (*nlarge)++;
+ packidx->hdr.large_offsets[packidx->nlargeobj] =
+ htobe64(obj->off);
+ packidx->nlargeobj++;
}
for (i = obj->id.sha1[0]; i <= 0xff; i++) {
@@ -421,7 +422,7 @@ index_pack(struct got_pack *pack, int idxfd, uint8_t *pack_hash,
struct got_packfile_hdr hdr;
struct got_packidx packidx;
char buf[8];
- int nobj, nvalid, nloose, nlarge = 0, nresolved = 0, i;
+ int nobj, nvalid, nloose, nresolved = 0, i;
struct got_indexed_object **objects = NULL, *obj;
SHA1_CTX ctx;
uint8_t packidx_hash[SHA1_DIGEST_LENGTH];
@@ -540,7 +541,7 @@ index_pack(struct got_pack *pack, int idxfd, uint8_t *pack_hash,
obj->type == GOT_OBJ_TYPE_TAG) {
objects[i]->valid = 1;
nloose++;
- update_packidx(&nlarge, &packidx, nobj, obj);
+ update_packidx(&packidx, nobj, obj);
}
}
nvalid = nloose;
@@ -581,7 +582,7 @@ index_pack(struct got_pack *pack, int idxfd, uint8_t *pack_hash,
objects[i]->valid = 1;
n++;
- update_packidx(&nlarge, &packidx, nobj, obj);
+ update_packidx(&packidx, nobj, obj);
err = got_privsep_send_index_pack_progress(ibuf, nobj, nobj,
nloose, nresolved + n);
if (err)
@@ -641,9 +642,9 @@ index_pack(struct got_pack *pack, int idxfd, uint8_t *pack_hash,
err = hwrite(idxfd, packidx.hdr.offsets, nobj * sizeof(uint32_t), &ctx);
if (err)
goto done;
- if (nlarge > 0) {
+ if (packidx.nlargeobj > 0) {
err = hwrite(idxfd, packidx.hdr.large_offsets,
- nlarge * sizeof(uint64_t), &ctx);
+ packidx.nlargeobj * sizeof(uint64_t), &ctx);
if (err)
goto done;
}