From: Dmitry S. Dolzhenko <hidden> Date: 2016-06-15 23:00:10
This version differs from previous [1] the following changes:
- added three new commits with similar changes in "builtin/mktree.c",
"cache-tree.c" and "sha1_file.c".
- updated commit messages: "use ALLOC_GROW() in function_name()" instead of
"change function_name() to use ALLOC_GROW()"
- updated [PATCH v2 01/11] [2] to keep code lines within 80 columns in
"builtin/pack-objects.c"
Duy Nguyen, Michael Haggerty, Junio C Hamano, Eric Sunshine, and He Sun,
thanks you very much for your remarks and advices
[1] http://thread.gmane.org/gmane.comp.version-control.git/242919
[2] http://thread.gmane.org/gmane.comp.version-control.git/242920
Dmitry S. Dolzhenko (14):
builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()
bundle.c: use ALLOC_GROW() in add_to_ref_list()
cache-tree.c: use ALLOC_GROW() in find_subtree()
commit.c: use ALLOC_GROW() in register_commit_graft()
diff.c: use ALLOC_GROW()
diffcore-rename.c: use ALLOC_GROW()
patch-ids.c: use ALLOC_GROW() in add_commit()
replace_object.c: use ALLOC_GROW() in register_replace_object()
reflog-walk.c: use ALLOC_GROW()
dir.c: use ALLOC_GROW() in create_simplify()
attr.c: use ALLOC_GROW() in handle_attr_line()
builtin/mktree.c: use ALLOC_GROW() in append_to_tree()
read-cache.c: use ALLOC_GROW() in add_index_entry()
sha1_file.c: use ALLOC_GROW() in pretend_sha1_file()
attr.c | 7 +------
builtin/mktree.c | 5 +----
builtin/pack-objects.c | 9 +++------
bundle.c | 6 +-----
cache-tree.c | 6 +-----
commit.c | 8 ++------
diff.c | 12 ++----------
diffcore-rename.c | 12 ++----------
dir.c | 5 +----
patch-ids.c | 5 +----
read-cache.c | 6 +-----
reflog-walk.c | 12 ++----------
replace_object.c | 8 ++------
sha1_file.c | 7 +------
14 files changed, 21 insertions(+), 87 deletions(-)
--
1.8.3.2
@@ -990,11 +990,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti}/* Make sure the array is big enough .. */-if(istate->cache_nr==istate->cache_alloc){-istate->cache_alloc=alloc_nr(istate->cache_alloc);-istate->cache=xrealloc(istate->cache,-istate->cache_alloc*sizeof(*istate->cache));-}+ALLOC_GROW(istate->cache,istate->cache_nr+1,istate->cache_alloc);/* Add it in.. */istate->cache_nr++;
@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,if(!insert_ok)returnNULL;/* insert to make it at "first" */-if(rename_dst_alloc<=rename_dst_nr){-rename_dst_alloc=alloc_nr(rename_dst_alloc);-rename_dst=xrealloc(rename_dst,-rename_dst_alloc*sizeof(*rename_dst));-}+ALLOC_GROW(rename_dst,rename_dst_nr+1,rename_dst_alloc);rename_dst_nr++;if(first<rename_dst_nr)memmove(rename_dst+first+1,rename_dst+first,
@@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)}/* insert to make it at "first" */-if(rename_src_alloc<=rename_src_nr){-rename_src_alloc=alloc_nr(rename_src_alloc);-rename_src=xrealloc(rename_src,-rename_src_alloc*sizeof(*rename_src));-}+ALLOC_GROW(rename_src,rename_src_nr+1,rename_src_alloc);rename_src_nr++;if(first<rename_src_nr)memmove(rename_src+first+1,rename_src+first,
@@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)return1;}pos=-pos-1;-if(commit_graft_alloc<=++commit_graft_nr){-commit_graft_alloc=alloc_nr(commit_graft_alloc);-commit_graft=xrealloc(commit_graft,-sizeof(*commit_graft)*-commit_graft_alloc);-}+ALLOC_GROW(commit_graft,commit_graft_nr+1,commit_graft_alloc);+commit_graft_nr++;if(pos<commit_graft_nr)memmove(commit_graft+pos+1,commit_graft+pos,