commit_tree: take a pointer/len pair rather than a const strbuf
[gitweb.git] / diffcore-rename.c
index 39effecd843a8ba0435246755ce12cfdaf6919c3..749a35d2c2ab3271c6503a19271a5be6a6e97b4d 100644 (file)
@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
        if (!insert_ok)
                return NULL;
        /* 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,