diff options
Diffstat (limited to 'pack-objects.c')
-rw-r--r-- | pack-objects.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/pack-objects.c b/pack-objects.c index d01d851ce9..6398a8aa96 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -7,10 +7,9 @@ static uint32_t locate_object_entry_hash(struct packing_data *pdata, const unsigned char *sha1, int *found) { - uint32_t i, hash, mask = (pdata->index_size - 1); + uint32_t i, mask = (pdata->index_size - 1); - memcpy(&hash, sha1, sizeof(uint32_t)); - i = hash & mask; + i = sha1hash(sha1) & mask; while (pdata->index[i] > 0) { uint32_t pos = pdata->index[i] - 1; @@ -47,8 +46,8 @@ static void rehash_objects(struct packing_data *pdata) if (pdata->index_size < 1024) pdata->index_size = 1024; - pdata->index = xrealloc(pdata->index, sizeof(uint32_t) * pdata->index_size); - memset(pdata->index, 0, sizeof(int) * pdata->index_size); + free(pdata->index); + pdata->index = xcalloc(pdata->index_size, sizeof(*pdata->index)); entry = pdata->objects; @@ -93,8 +92,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata, if (pdata->nr_objects >= pdata->nr_alloc) { pdata->nr_alloc = (pdata->nr_alloc + 1024) * 3 / 2; - pdata->objects = xrealloc(pdata->objects, - pdata->nr_alloc * sizeof(*new_entry)); + REALLOC_ARRAY(pdata->objects, pdata->nr_alloc); } new_entry = pdata->objects + pdata->nr_objects++; |