diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-03-18 13:50:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-03-18 13:50:21 -0700 |
commit | fe9122a35213827348c521a16ffd0cf2652c4ac5 (patch) | |
tree | 7feb62b93a1b90ad365f582e926c11b75d847686 /diff.c | |
parent | a8e1d711cc9531463fe312875553d56624eb9c37 (diff) | |
parent | c7353967ca8ede681e9f8fbac98a650450631990 (diff) | |
download | git-fe9122a35213827348c521a16ffd0cf2652c4ac5.tar.gz git-fe9122a35213827348c521a16ffd0cf2652c4ac5.tar.xz |
Merge branch 'dd/use-alloc-grow'
Replace open-coded reallocation with ALLOC_GROW() macro.
* dd/use-alloc-grow:
sha1_file.c: use ALLOC_GROW() in pretend_sha1_file()
read-cache.c: use ALLOC_GROW() in add_index_entry()
builtin/mktree.c: use ALLOC_GROW() in append_to_tree()
attr.c: use ALLOC_GROW() in handle_attr_line()
dir.c: use ALLOC_GROW() in create_simplify()
reflog-walk.c: use ALLOC_GROW()
replace_object.c: use ALLOC_GROW() in register_replace_object()
patch-ids.c: use ALLOC_GROW() in add_commit()
diffcore-rename.c: use ALLOC_GROW()
diff.c: use ALLOC_GROW()
commit.c: use ALLOC_GROW() in register_commit_graft()
cache-tree.c: use ALLOC_GROW() in find_subtree()
bundle.c: use ALLOC_GROW() in add_to_ref_list()
builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 12 |
1 files changed, 2 insertions, 10 deletions
@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat, { struct diffstat_file *x; x = xcalloc(sizeof (*x), 1); - if (diffstat->nr == diffstat->alloc) { - diffstat->alloc = alloc_nr(diffstat->alloc); - diffstat->files = xrealloc(diffstat->files, - diffstat->alloc * sizeof(x)); - } + ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc); diffstat->files[diffstat->nr++] = x; if (name_b) { x->from_name = xstrdup(name_a); @@ -3958,11 +3954,7 @@ struct diff_queue_struct diff_queued_diff; void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp) { - if (queue->alloc <= queue->nr) { - queue->alloc = alloc_nr(queue->alloc); - queue->queue = xrealloc(queue->queue, - sizeof(dp) * queue->alloc); - } + ALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc); queue->queue[queue->nr++] = dp; } |