X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=pack-objects.c;h=9992f3ecf249c32e5be31dc047bad46a4c4ac367;hb=039dc71a7cb824300e242f8abc0fcb19dac93641;hp=d01d851ce957c779ff98d243fea4476fa7a1008c;hpb=7461a3e9fca9b73e35386a1d8a2de2cf8b444871;p=thirdparty%2Fgit.git diff --git a/pack-objects.c b/pack-objects.c index d01d851ce9..9992f3ecf2 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;