Skip to content

Commit 5327207

Browse files
committed
Merge branch 'rs/pack-objects-no-unnecessary-realloc' into maint
"git pack-objects" unnecessarily copied the previous contents when extending the hashtable, even though it will populate the table from scratch anyway. * rs/pack-objects-no-unnecessary-realloc: pack-objects: use free()+xcalloc() instead of xrealloc()+memset()
2 parents 5fa38cc + fb79947 commit 5327207

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ static void rehash_objects(struct packing_data *pdata)
4747
if (pdata->index_size < 1024)
4848
pdata->index_size = 1024;
4949

50-
pdata->index = xrealloc(pdata->index, sizeof(uint32_t) * pdata->index_size);
51-
memset(pdata->index, 0, sizeof(int) * pdata->index_size);
50+
free(pdata->index);
51+
pdata->index = xcalloc(pdata->index_size, sizeof(*pdata->index));
5252

5353
entry = pdata->objects;
5454

0 commit comments

Comments
 (0)