commit - 51a494da48acb57ed84501a6d10f39ed624c711e
commit + e89540a95a268f47ef2d1b24c41fbb72a1f0bdc9
blob - 5249f06a3d371504ab13da934648a6a7e7afe141
blob + 93610404be5f10c352889a9f87c927eeecb91e11
--- lib/deltify.c
+++ lib/deltify.c
addblk(struct got_delta_table *dt, FILE *f, off_t len, off_t offset, uint64_t h)
{
const struct got_error *err = NULL;
- int i, nalloc;
+ int i;
uint8_t buf[GOT_DELTIFY_MAXCHUNK];
size_t r = 0;
dt->blocks[i].offset = offset;
dt->blocks[i].hash = h;
dt->nblocks++;
- if (dt->nalloc < 2 * dt->nblocks) {
+ if (dt->nalloc < dt->nblocks + 64) {
struct got_delta_block *db;
- nalloc = dt->nalloc * 2;
+ size_t old_size = dt->nalloc;
db = dt->blocks;
- dt->blocks = calloc(nalloc, sizeof(struct got_delta_block));
+ dt->blocks = calloc(dt->nalloc + 64,
+ sizeof(struct got_delta_block));
if (dt->blocks == NULL) {
err = got_error_from_errno("calloc");
dt->blocks = db;
return err;
}
- dt->nalloc = nalloc;
+ dt->nalloc += 64;
/*
* Recompute all block positions. Hash-based indices of blocks
* in the array depend on the allocated length of the array.