Skip to content

Commit

Permalink
Merge branch 'rs/pack-objects-no-unnecessary-realloc'
Browse files Browse the repository at this point in the history
Avoid unnecessary copy of previous contents when extending the
hashtable used in pack-objects.

* rs/pack-objects-no-unnecessary-realloc:
  pack-objects: use free()+xcalloc() instead of xrealloc()+memset()
  • Loading branch information
Junio C Hamano committed Jun 16, 2014
2 parents 3009afd + fb79947 commit 57a2eee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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;

Expand Down

0 comments on commit 57a2eee

Please sign in to comment.