{"thread":{"id":"35982","subject":"[PATCH] Use ALLOC_GROW() instead of inline code","startedAt":"2014-02-27T20:45:27Z","lastAt":"2014-03-03T19:07:12Z","messageCount":42,"participants":["Dmitry S. Dolzhenko","Michael Haggerty","Junio C Hamano","Duy Nguyen","Jeff King","Eric Sunshine","He Sun"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"235509","messageId":"530FA3E7.8020200@yandex.ru","threadId":"35982","inReplyTo":null,"subject":"[PATCH] Use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-27T20:45:27Z","receivedAt":"2014-02-27T20:45:27Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@gmail.com>\n---\n attr.c                 |  7 +------\n builtin/pack-objects.c |  7 +------\n bundle.c               |  6 +-----\n cache-tree.c           |  6 +-----\n commit.c               |  8 ++------\n diff.c                 | 12 ++----------\n diffcore-rename.c      | 12 ++----------\n dir.c                  |  5 +----\n patch-ids.c            |  5 +----\n read-cache.c           |  9 ++-------\n reflog-walk.c          | 13 +++----------\n replace_object.c       |  8 ++------\n 12 files changed, 19 insertions(+), 79 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 8d13d70..734222d 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,\n \ta = parse_attr_line(line, src, lineno, macro_ok);\n \tif (!a)\n \t\treturn;\n-\tif (res->alloc <= res->num_matches) {\n-\t\tres->alloc = alloc_nr(res->num_matches);\n-\t\tres->attrs = xrealloc(res->attrs,\n-\t\t\t\t      sizeof(struct match_attr *) *\n-\t\t\t\t      res->alloc);\n-\t}\n+\tALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);\n \tres->attrs[res->num_matches++] = a;\n }\n \ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 541667f..92cbce8 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1156,12 +1156,7 @@ static int check_pbase_path(unsigned hash)\n \tif (0 <= pos)\n \t\treturn 1;\n \tpos = -pos - 1;\n-\tif (done_pbase_paths_alloc <= done_pbase_paths_num) {\n-\t\tdone_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n-\t\tdone_pbase_paths = xrealloc(done_pbase_paths,\n-\t\t\t\t\t    done_pbase_paths_alloc *\n-\t\t\t\t\t    sizeof(unsigned));\n-\t}\n+\tALLOC_GROW(done_pbase_paths, done_pbase_paths_num + 1, done_pbase_paths_alloc);\n \tdone_pbase_paths_num++;\n \tif (pos < done_pbase_paths_num)\n \t\tmemmove(done_pbase_paths + pos + 1,\ndiff --git a/bundle.c b/bundle.c\nindex e99065c..1388a3e 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n static void add_to_ref_list(const unsigned char *sha1, const char *name,\n \t\tstruct ref_list *list)\n {\n-\tif (list->nr + 1 >= list->alloc) {\n-\t\tlist->alloc = alloc_nr(list->nr + 1);\n-\t\tlist->list = xrealloc(list->list,\n-\t\t\t\tlist->alloc * sizeof(list->list[0]));\n-\t}\n+\tALLOC_GROW(list->list, list->nr + 1, list->alloc);\n \tmemcpy(list->list[list->nr].sha1, sha1, 20);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 0bbec43..30149d1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,\n \t\treturn NULL;\n \n \tpos = -pos-1;\n-\tif (it->subtree_alloc <= it->subtree_nr) {\n-\t\tit->subtree_alloc = alloc_nr(it->subtree_alloc);\n-\t\tit->down = xrealloc(it->down, it->subtree_alloc *\n-\t\t\t\t    sizeof(*it->down));\n-\t}\n+\tALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);\n \tit->subtree_nr++;\n \n \tdown = xmalloc(sizeof(*down) + pathlen + 1);\ndiff --git a/commit.c b/commit.c\nindex 6bf4fe0..e004314 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (commit_graft_alloc <= ++commit_graft_nr) {\n-\t\tcommit_graft_alloc = alloc_nr(commit_graft_alloc);\n-\t\tcommit_graft = xrealloc(commit_graft,\n-\t\t\t\t\tsizeof(*commit_graft) *\n-\t\t\t\t\tcommit_graft_alloc);\n-\t}\n+\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n+\tcommit_graft_nr++;\n \tif (pos < commit_graft_nr)\n \t\tmemmove(commit_graft + pos + 1,\n \t\t\tcommit_graft + pos,\ndiff --git a/diff.c b/diff.c\nindex 8e4a6a9..f5f0fd1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n {\n \tstruct diffstat_file *x;\n \tx = xcalloc(sizeof (*x), 1);\n-\tif (diffstat->nr == diffstat->alloc) {\n-\t\tdiffstat->alloc = alloc_nr(diffstat->alloc);\n-\t\tdiffstat->files = xrealloc(diffstat->files,\n-\t\t\t\tdiffstat->alloc * sizeof(x));\n-\t}\n+\tALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);\n \tdiffstat->files[diffstat->nr++] = x;\n \tif (name_b) {\n \t\tx->from_name = xstrdup(name_a);\n@@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n {\n-\tif (queue->alloc <= queue->nr) {\n-\t\tqueue->alloc = alloc_nr(queue->alloc);\n-\t\tqueue->queue = xrealloc(queue->queue,\n-\t\t\t\t\tsizeof(dp) * queue->alloc);\n-\t}\n+\tALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);\n \tqueue->queue[queue->nr++] = dp;\n }\n \ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 6c7a72f..f54d5bf 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,\n \tif (!insert_ok)\n \t\treturn NULL;\n \t/* insert to make it at \"first\" */\n-\tif (rename_dst_alloc <= rename_dst_nr) {\n-\t\trename_dst_alloc = alloc_nr(rename_dst_alloc);\n-\t\trename_dst = xrealloc(rename_dst,\n-\t\t\t\t      rename_dst_alloc * sizeof(*rename_dst));\n-\t}\n+\tALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);\n \trename_dst_nr++;\n \tif (first < rename_dst_nr)\n \t\tmemmove(rename_dst + first + 1, rename_dst + first,\n@@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)\n \t}\n \n \t/* insert to make it at \"first\" */\n-\tif (rename_src_alloc <= rename_src_nr) {\n-\t\trename_src_alloc = alloc_nr(rename_src_alloc);\n-\t\trename_src = xrealloc(rename_src,\n-\t\t\t\t      rename_src_alloc * sizeof(*rename_src));\n-\t}\n+\tALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);\n \trename_src_nr++;\n \tif (first < rename_src_nr)\n \t\tmemmove(rename_src + first + 1, rename_src + first,\ndiff --git a/dir.c b/dir.c\nindex b35b633..72f6e2a 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1329,13 +1329,10 @@ static struct path_simplify *create_simplify(const char **pathspec)\n \n \tfor (nr = 0 ; ; nr++) {\n \t\tconst char *match;\n-\t\tif (nr >= alloc) {\n-\t\t\talloc = alloc_nr(alloc);\n-\t\t\tsimplify = xrealloc(simplify, alloc * sizeof(*simplify));\n-\t\t}\n \t\tmatch = *pathspec++;\n \t\tif (!match)\n \t\t\tbreak;\n+\t\tALLOC_GROW(simplify, nr + 1, alloc);\n \t\tsimplify[nr].path = match;\n \t\tsimplify[nr].len = simple_length(match);\n \t}\ndiff --git a/patch-ids.c b/patch-ids.c\nindex bc8a28f..bf81b92 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -83,10 +83,7 @@ static struct patch_id *add_commit(struct commit *commit,\n \tent = &bucket->bucket[bucket->nr++];\n \thashcpy(ent->patch_id, sha1);\n \n-\tif (ids->alloc <= ids->nr) {\n-\t\tids->alloc = alloc_nr(ids->nr);\n-\t\tids->table = xrealloc(ids->table, sizeof(ent) * ids->alloc);\n-\t}\n+\tALLOC_GROW(ids->table, ids->nr + 1, ids->alloc);\n \tif (pos < ids->nr)\n \t\tmemmove(ids->table + pos + 1, ids->table + pos,\n \t\t\tsizeof(ent) * (ids->nr - pos));\ndiff --git a/read-cache.c b/read-cache.c\nindex 33dd676..e585541 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -993,11 +993,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti\n \t}\n \n \t/* Make sure the array is big enough .. */\n-\tif (istate->cache_nr == istate->cache_alloc) {\n-\t\tistate->cache_alloc = alloc_nr(istate->cache_alloc);\n-\t\tistate->cache = xrealloc(istate->cache,\n-\t\t\t\t\tistate->cache_alloc * sizeof(*istate->cache));\n-\t}\n+\tALLOC_GROW(istate->cache, istate->cache_nr + 1, istate->cache_alloc);\n \n \t/* Add it in.. */\n \tistate->cache_nr++;\n@@ -1466,8 +1462,7 @@ int read_index_from(struct index_state *istate, const char *path)\n \n \tistate->version = ntohl(hdr->hdr_version);\n \tistate->cache_nr = ntohl(hdr->hdr_entries);\n-\tistate->cache_alloc = alloc_nr(istate->cache_nr);\n-\tistate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));\n+\tALLOC_GROW(istate->cache, istate->cache_nr, istate->cache_alloc);\n \tistate->initialized = 1;\n \n \tif (istate->version == 4)\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex b2fbdb2..879d2ed 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,\n \tstruct complete_reflogs *array = cb_data;\n \tstruct reflog_info *item;\n \n-\tif (array->nr >= array->alloc) {\n-\t\tarray->alloc = alloc_nr(array->nr + 1);\n-\t\tarray->items = xrealloc(array->items, array->alloc *\n-\t\t\tsizeof(struct reflog_info));\n-\t}\n+\tALLOC_GROW(array->items, array->nr + 1, array->alloc);\n \titem = array->items + array->nr;\n \tmemcpy(item->osha1, osha1, 20);\n \tmemcpy(item->nsha1, nsha1, 20);\n@@ -114,11 +110,8 @@ static void add_commit_info(struct commit *commit, void *util,\n \t\tstruct commit_info_lifo *lifo)\n {\n \tstruct commit_info *info;\n-\tif (lifo->nr >= lifo->alloc) {\n-\t\tlifo->alloc = alloc_nr(lifo->nr + 1);\n-\t\tlifo->items = xrealloc(lifo->items,\n-\t\t\tlifo->alloc * sizeof(struct commit_info));\n-\t}\n+\n+\tALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);\n \tinfo = lifo->items + lifo->nr;\n \tinfo->commit = commit;\n \tinfo->util = util;\ndiff --git a/replace_object.c b/replace_object.c\nindex cdcaf8c..843deef 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -36,12 +36,8 @@ static int register_replace_object(struct replace_object *replace,\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (replace_object_alloc <= ++replace_object_nr) {\n-\t\treplace_object_alloc = alloc_nr(replace_object_alloc);\n-\t\treplace_object = xrealloc(replace_object,\n-\t\t\t\t\t  sizeof(*replace_object) *\n-\t\t\t\t\t  replace_object_alloc);\n-\t}\n+\tALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);\n+\treplace_object_nr++;\n \tif (pos < replace_object_nr)\n \t\tmemmove(replace_object + pos + 1,\n \t\t\treplace_object + pos,\n-- \n1.8.3.2\n"},{"id":"235517","messageId":"530FB82C.70005@alum.mit.edu","threadId":"35982","inReplyTo":"530FA3E7.8020200@yandex.ru","subject":"Re: [PATCH] Use ALLOC_GROW() instead of inline code","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-27T22:11:56Z","receivedAt":"2014-02-27T22:11:56Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Dmitry,\n\nThat's cool; I never imagined there would be so many sites that could be\ncleaned up in this way.\n\nIn my opinion, it would be preferable for this patch to be broken into\nmultiple commits, one for each site (or each file, if a file has\nmultiple sites that are logically related).  That would make it easier\nto review the patches and easier to bisect if we later find a problem.\nPlease make sure that you note if there are any sites where the\nrewritten code doesn't have exactly the same semantics as the original\n(I don't know if there are sites like this, but if there are...).  That\nhelps reviewers focus on the changes that might be \"controversial\".\n\n[Please leave the other microprojects for other students (I just wrote\nan email on this topic).]\n\nThanks,\nMichael\n\nOn 02/27/2014 09:45 PM, Dmitry S. Dolzhenko wrote:\n> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@gmail.com>\n> ---\n>  attr.c                 |  7 +------\n>  builtin/pack-objects.c |  7 +------\n>  bundle.c               |  6 +-----\n>  cache-tree.c           |  6 +-----\n>  commit.c               |  8 ++------\n>  diff.c                 | 12 ++----------\n>  diffcore-rename.c      | 12 ++----------\n>  dir.c                  |  5 +----\n>  patch-ids.c            |  5 +----\n>  read-cache.c           |  9 ++-------\n>  reflog-walk.c          | 13 +++----------\n>  replace_object.c       |  8 ++------\n>  12 files changed, 19 insertions(+), 79 deletions(-)\n> \n> diff --git a/attr.c b/attr.c\n> index 8d13d70..734222d 100644\n> --- a/attr.c\n> +++ b/attr.c\n> @@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,\n>  \ta = parse_attr_line(line, src, lineno, macro_ok);\n>  \tif (!a)\n>  \t\treturn;\n> -\tif (res->alloc <= res->num_matches) {\n> -\t\tres->alloc = alloc_nr(res->num_matches);\n> -\t\tres->attrs = xrealloc(res->attrs,\n> -\t\t\t\t      sizeof(struct match_attr *) *\n> -\t\t\t\t      res->alloc);\n> -\t}\n> +\tALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);\n>  \tres->attrs[res->num_matches++] = a;\n>  }\n>  \n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> index 541667f..92cbce8 100644\n> --- a/builtin/pack-objects.c\n> +++ b/builtin/pack-objects.c\n> @@ -1156,12 +1156,7 @@ static int check_pbase_path(unsigned hash)\n>  \tif (0 <= pos)\n>  \t\treturn 1;\n>  \tpos = -pos - 1;\n> -\tif (done_pbase_paths_alloc <= done_pbase_paths_num) {\n> -\t\tdone_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n> -\t\tdone_pbase_paths = xrealloc(done_pbase_paths,\n> -\t\t\t\t\t    done_pbase_paths_alloc *\n> -\t\t\t\t\t    sizeof(unsigned));\n> -\t}\n> +\tALLOC_GROW(done_pbase_paths, done_pbase_paths_num + 1, done_pbase_paths_alloc);\n>  \tdone_pbase_paths_num++;\n>  \tif (pos < done_pbase_paths_num)\n>  \t\tmemmove(done_pbase_paths + pos + 1,\n> diff --git a/bundle.c b/bundle.c\n> index e99065c..1388a3e 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n>  static void add_to_ref_list(const unsigned char *sha1, const char *name,\n>  \t\tstruct ref_list *list)\n>  {\n> -\tif (list->nr + 1 >= list->alloc) {\n> -\t\tlist->alloc = alloc_nr(list->nr + 1);\n> -\t\tlist->list = xrealloc(list->list,\n> -\t\t\t\tlist->alloc * sizeof(list->list[0]));\n> -\t}\n> +\tALLOC_GROW(list->list, list->nr + 1, list->alloc);\n>  \tmemcpy(list->list[list->nr].sha1, sha1, 20);\n>  \tlist->list[list->nr].name = xstrdup(name);\n>  \tlist->nr++;\n> diff --git a/cache-tree.c b/cache-tree.c\n> index 0bbec43..30149d1 100644\n> --- a/cache-tree.c\n> +++ b/cache-tree.c\n> @@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,\n>  \t\treturn NULL;\n>  \n>  \tpos = -pos-1;\n> -\tif (it->subtree_alloc <= it->subtree_nr) {\n> -\t\tit->subtree_alloc = alloc_nr(it->subtree_alloc);\n> -\t\tit->down = xrealloc(it->down, it->subtree_alloc *\n> -\t\t\t\t    sizeof(*it->down));\n> -\t}\n> +\tALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);\n>  \tit->subtree_nr++;\n>  \n>  \tdown = xmalloc(sizeof(*down) + pathlen + 1);\n> diff --git a/commit.c b/commit.c\n> index 6bf4fe0..e004314 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n>  \t\treturn 1;\n>  \t}\n>  \tpos = -pos - 1;\n> -\tif (commit_graft_alloc <= ++commit_graft_nr) {\n> -\t\tcommit_graft_alloc = alloc_nr(commit_graft_alloc);\n> -\t\tcommit_graft = xrealloc(commit_graft,\n> -\t\t\t\t\tsizeof(*commit_graft) *\n> -\t\t\t\t\tcommit_graft_alloc);\n> -\t}\n> +\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n> +\tcommit_graft_nr++;\n>  \tif (pos < commit_graft_nr)\n>  \t\tmemmove(commit_graft + pos + 1,\n>  \t\t\tcommit_graft + pos,\n> diff --git a/diff.c b/diff.c\n> index 8e4a6a9..f5f0fd1 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n>  {\n>  \tstruct diffstat_file *x;\n>  \tx = xcalloc(sizeof (*x), 1);\n> -\tif (diffstat->nr == diffstat->alloc) {\n> -\t\tdiffstat->alloc = alloc_nr(diffstat->alloc);\n> -\t\tdiffstat->files = xrealloc(diffstat->files,\n> -\t\t\t\tdiffstat->alloc * sizeof(x));\n> -\t}\n> +\tALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);\n>  \tdiffstat->files[diffstat->nr++] = x;\n>  \tif (name_b) {\n>  \t\tx->from_name = xstrdup(name_a);\n> @@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;\n>  \n>  void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n>  {\n> -\tif (queue->alloc <= queue->nr) {\n> -\t\tqueue->alloc = alloc_nr(queue->alloc);\n> -\t\tqueue->queue = xrealloc(queue->queue,\n> -\t\t\t\t\tsizeof(dp) * queue->alloc);\n> -\t}\n> +\tALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);\n>  \tqueue->queue[queue->nr++] = dp;\n>  }\n>  \n> diff --git a/diffcore-rename.c b/diffcore-rename.c\n> index 6c7a72f..f54d5bf 100644\n> --- a/diffcore-rename.c\n> +++ b/diffcore-rename.c\n> @@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,\n>  \tif (!insert_ok)\n>  \t\treturn NULL;\n>  \t/* insert to make it at \"first\" */\n> -\tif (rename_dst_alloc <= rename_dst_nr) {\n> -\t\trename_dst_alloc = alloc_nr(rename_dst_alloc);\n> -\t\trename_dst = xrealloc(rename_dst,\n> -\t\t\t\t      rename_dst_alloc * sizeof(*rename_dst));\n> -\t}\n> +\tALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);\n>  \trename_dst_nr++;\n>  \tif (first < rename_dst_nr)\n>  \t\tmemmove(rename_dst + first + 1, rename_dst + first,\n> @@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)\n>  \t}\n>  \n>  \t/* insert to make it at \"first\" */\n> -\tif (rename_src_alloc <= rename_src_nr) {\n> -\t\trename_src_alloc = alloc_nr(rename_src_alloc);\n> -\t\trename_src = xrealloc(rename_src,\n> -\t\t\t\t      rename_src_alloc * sizeof(*rename_src));\n> -\t}\n> +\tALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);\n>  \trename_src_nr++;\n>  \tif (first < rename_src_nr)\n>  \t\tmemmove(rename_src + first + 1, rename_src + first,\n> diff --git a/dir.c b/dir.c\n> index b35b633..72f6e2a 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -1329,13 +1329,10 @@ static struct path_simplify *create_simplify(const char **pathspec)\n>  \n>  \tfor (nr = 0 ; ; nr++) {\n>  \t\tconst char *match;\n> -\t\tif (nr >= alloc) {\n> -\t\t\talloc = alloc_nr(alloc);\n> -\t\t\tsimplify = xrealloc(simplify, alloc * sizeof(*simplify));\n> -\t\t}\n>  \t\tmatch = *pathspec++;\n>  \t\tif (!match)\n>  \t\t\tbreak;\n> +\t\tALLOC_GROW(simplify, nr + 1, alloc);\n>  \t\tsimplify[nr].path = match;\n>  \t\tsimplify[nr].len = simple_length(match);\n>  \t}\n> diff --git a/patch-ids.c b/patch-ids.c\n> index bc8a28f..bf81b92 100644\n> --- a/patch-ids.c\n> +++ b/patch-ids.c\n> @@ -83,10 +83,7 @@ static struct patch_id *add_commit(struct commit *commit,\n>  \tent = &bucket->bucket[bucket->nr++];\n>  \thashcpy(ent->patch_id, sha1);\n>  \n> -\tif (ids->alloc <= ids->nr) {\n> -\t\tids->alloc = alloc_nr(ids->nr);\n> -\t\tids->table = xrealloc(ids->table, sizeof(ent) * ids->alloc);\n> -\t}\n> +\tALLOC_GROW(ids->table, ids->nr + 1, ids->alloc);\n>  \tif (pos < ids->nr)\n>  \t\tmemmove(ids->table + pos + 1, ids->table + pos,\n>  \t\t\tsizeof(ent) * (ids->nr - pos));\n> diff --git a/read-cache.c b/read-cache.c\n> index 33dd676..e585541 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -993,11 +993,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti\n>  \t}\n>  \n>  \t/* Make sure the array is big enough .. */\n> -\tif (istate->cache_nr == istate->cache_alloc) {\n> -\t\tistate->cache_alloc = alloc_nr(istate->cache_alloc);\n> -\t\tistate->cache = xrealloc(istate->cache,\n> -\t\t\t\t\tistate->cache_alloc * sizeof(*istate->cache));\n> -\t}\n> +\tALLOC_GROW(istate->cache, istate->cache_nr + 1, istate->cache_alloc);\n>  \n>  \t/* Add it in.. */\n>  \tistate->cache_nr++;\n> @@ -1466,8 +1462,7 @@ int read_index_from(struct index_state *istate, const char *path)\n>  \n>  \tistate->version = ntohl(hdr->hdr_version);\n>  \tistate->cache_nr = ntohl(hdr->hdr_entries);\n> -\tistate->cache_alloc = alloc_nr(istate->cache_nr);\n> -\tistate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));\n> +\tALLOC_GROW(istate->cache, istate->cache_nr, istate->cache_alloc);\n>  \tistate->initialized = 1;\n>  \n>  \tif (istate->version == 4)\n> diff --git a/reflog-walk.c b/reflog-walk.c\n> index b2fbdb2..879d2ed 100644\n> --- a/reflog-walk.c\n> +++ b/reflog-walk.c\n> @@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,\n>  \tstruct complete_reflogs *array = cb_data;\n>  \tstruct reflog_info *item;\n>  \n> -\tif (array->nr >= array->alloc) {\n> -\t\tarray->alloc = alloc_nr(array->nr + 1);\n> -\t\tarray->items = xrealloc(array->items, array->alloc *\n> -\t\t\tsizeof(struct reflog_info));\n> -\t}\n> +\tALLOC_GROW(array->items, array->nr + 1, array->alloc);\n>  \titem = array->items + array->nr;\n>  \tmemcpy(item->osha1, osha1, 20);\n>  \tmemcpy(item->nsha1, nsha1, 20);\n> @@ -114,11 +110,8 @@ static void add_commit_info(struct commit *commit, void *util,\n>  \t\tstruct commit_info_lifo *lifo)\n>  {\n>  \tstruct commit_info *info;\n> -\tif (lifo->nr >= lifo->alloc) {\n> -\t\tlifo->alloc = alloc_nr(lifo->nr + 1);\n> -\t\tlifo->items = xrealloc(lifo->items,\n> -\t\t\tlifo->alloc * sizeof(struct commit_info));\n> -\t}\n> +\n> +\tALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);\n>  \tinfo = lifo->items + lifo->nr;\n>  \tinfo->commit = commit;\n>  \tinfo->util = util;\n> diff --git a/replace_object.c b/replace_object.c\n> index cdcaf8c..843deef 100644\n> --- a/replace_object.c\n> +++ b/replace_object.c\n> @@ -36,12 +36,8 @@ static int register_replace_object(struct replace_object *replace,\n>  \t\treturn 1;\n>  \t}\n>  \tpos = -pos - 1;\n> -\tif (replace_object_alloc <= ++replace_object_nr) {\n> -\t\treplace_object_alloc = alloc_nr(replace_object_alloc);\n> -\t\treplace_object = xrealloc(replace_object,\n> -\t\t\t\t\t  sizeof(*replace_object) *\n> -\t\t\t\t\t  replace_object_alloc);\n> -\t}\n> +\tALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);\n> +\treplace_object_nr++;\n>  \tif (pos < replace_object_nr)\n>  \t\tmemmove(replace_object + pos + 1,\n>  \t\t\treplace_object + pos,\n> \n\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"235523","messageId":"xmqqr46ow4zs.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"530FA3E7.8020200@yandex.ru","subject":"Re: [PATCH] Use ALLOC_GROW() instead of inline code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-27T22:44:07Z","receivedAt":"2014-02-27T22:44:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Dmitry S. Dolzhenko\" <dmitrys.dolzhenko@yandex.ru> writes:\n\n> diff --git a/dir.c b/dir.c\n> index b35b633..72f6e2a 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -1329,13 +1329,10 @@ static struct path_simplify *create_simplify(const char **pathspec)\n>  \n>  \tfor (nr = 0 ; ; nr++) {\n>  \t\tconst char *match;\n> -\t\tif (nr >= alloc) {\n> -\t\t\talloc = alloc_nr(alloc);\n> -\t\t\tsimplify = xrealloc(simplify, alloc * sizeof(*simplify));\n> -\t\t}\n>  \t\tmatch = *pathspec++;\n>  \t\tif (!match)\n>  \t\t\tbreak;\n> +\t\tALLOC_GROW(simplify, nr + 1, alloc);\n>  \t\tsimplify[nr].path = match;\n>  \t\tsimplify[nr].len = simple_length(match);\n>  \t}\n\nWhat follows the post-context of this hunk is a NULL termination of\nthe array:\n\n\tsimplify[nr].path = NULL;\n        simplify[nr].len = 0;\n\nIf the first element in pathspec[] were NULL, we set nr to 0, break\nthe loop without calling ALLOC_GROW() even once, and try to NULL\nterminate simplify[] array after the loop.\n\nDon't we try to store to an unallocated piece of memory with this\nchange?\n\n> diff --git a/read-cache.c b/read-cache.c\n> index 33dd676..e585541 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -1466,8 +1462,7 @@ int read_index_from(struct index_state *istate, const char *path)\n>  \n>  \tistate->version = ntohl(hdr->hdr_version);\n>  \tistate->cache_nr = ntohl(hdr->hdr_entries);\n> -\tistate->cache_alloc = alloc_nr(istate->cache_nr);\n> -\tistate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));\n> +\tALLOC_GROW(istate->cache, istate->cache_nr, istate->cache_alloc);\n\nThis being the initial allocation, not growing reallocation, use of\nALLOC_GROW() looks somewhat strange.  I know that an realloc from\nNULL ends up being the same as calloc(), but still.\n"},{"id":"235570","messageId":"531056E7.3010305@yandex.ru","threadId":"35982","inReplyTo":"530FA3E7.8020200@yandex.ru","subject":"[PATCH v2 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:29:11Z","receivedAt":"2014-02-28T09:29:11Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Thank you for your remarks. In this patch I tried to take them into account.\n\nDmitry S. Dolzhenko (11):\n  builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()\n  bundle.c: change add_to_ref_list() to use ALLOC_GROW()\n  cache-tree.c: change find_subtree() to use ALLOC_GROW()\n  commit.c: change register_commit_graft() to use ALLOC_GROW()\n  diff.c: use ALLOC_GROW() instead of inline code\n  diffcore-rename.c: use ALLOC_GROW() instead of inline code\n  patch-ids.c: change add_commit() to use ALLOC_GROW()\n  replace_object.c: change register_replace_object() to use ALLOC_GROW()\n  reflog-walk.c: use ALLOC_GROW() instead of inline code\n  dir.c: change create_simplify() to use ALLOC_GROW()\n  attr.c: change handle_attr_line() to use ALLOC_GROW()\n\n attr.c                 |  7 +------\n builtin/pack-objects.c |  7 +------\n bundle.c               |  6 +-----\n cache-tree.c           |  6 +-----\n commit.c               |  8 ++------\n diff.c                 | 12 ++----------\n diffcore-rename.c      | 12 ++----------\n dir.c                  |  5 +----\n patch-ids.c            |  5 +----\n reflog-walk.c          | 13 +++----------\n replace_object.c       |  8 ++------\n 11 files changed, 17 insertions(+), 72 deletions(-)\n\n-- \n1.8.5.3\n"},{"id":"235571","messageId":"53105995.3010001@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:40:37Z","receivedAt":"2014-02-28T09:40:37Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n builtin/pack-objects.c | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex c733379..56a6fc8 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1213,12 +1213,7 @@ static int check_pbase_path(unsigned hash)\n \tif (0 <= pos)\n \t\treturn 1;\n \tpos = -pos - 1;\n-\tif (done_pbase_paths_alloc <= done_pbase_paths_num) {\n-\t\tdone_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n-\t\tdone_pbase_paths = xrealloc(done_pbase_paths,\n-\t\t\t\t\t    done_pbase_paths_alloc *\n-\t\t\t\t\t    sizeof(unsigned));\n-\t}\n+\tALLOC_GROW(done_pbase_paths, done_pbase_paths_num + 1, done_pbase_paths_alloc);\n \tdone_pbase_paths_num++;\n \tif (pos < done_pbase_paths_num)\n \t\tmemmove(done_pbase_paths + pos + 1,\n-- \n1.8.5.3\n"},{"id":"235572","messageId":"531059CA.4020700@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 02/11] bundle.c: change add_to_ref_list() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:41:30Z","receivedAt":"2014-02-28T09:41:30Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n bundle.c | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex e99065c..1388a3e 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n static void add_to_ref_list(const unsigned char *sha1, const char *name,\n \t\tstruct ref_list *list)\n {\n-\tif (list->nr + 1 >= list->alloc) {\n-\t\tlist->alloc = alloc_nr(list->nr + 1);\n-\t\tlist->list = xrealloc(list->list,\n-\t\t\t\tlist->alloc * sizeof(list->list[0]));\n-\t}\n+\tALLOC_GROW(list->list, list->nr + 1, list->alloc);\n \tmemcpy(list->list[list->nr].sha1, sha1, 20);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\n-- \n1.8.5.3\n"},{"id":"235573","messageId":"531059E7.4030406@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 03/11] cache-tree.c: change find_subtree() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:41:59Z","receivedAt":"2014-02-28T09:41:59Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n cache-tree.c | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 0bbec43..30149d1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,\n \t\treturn NULL;\n \n \tpos = -pos-1;\n-\tif (it->subtree_alloc <= it->subtree_nr) {\n-\t\tit->subtree_alloc = alloc_nr(it->subtree_alloc);\n-\t\tit->down = xrealloc(it->down, it->subtree_alloc *\n-\t\t\t\t    sizeof(*it->down));\n-\t}\n+\tALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);\n \tit->subtree_nr++;\n \n \tdown = xmalloc(sizeof(*down) + pathlen + 1);\n-- \n1.8.5.3\n"},{"id":"235574","messageId":"53105A13.9070704@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 04/11] commit.c: change register_commit_graft() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:42:43Z","receivedAt":"2014-02-28T09:42:43Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n commit.c | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 6bf4fe0..e004314 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (commit_graft_alloc <= ++commit_graft_nr) {\n-\t\tcommit_graft_alloc = alloc_nr(commit_graft_alloc);\n-\t\tcommit_graft = xrealloc(commit_graft,\n-\t\t\t\t\tsizeof(*commit_graft) *\n-\t\t\t\t\tcommit_graft_alloc);\n-\t}\n+\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n+\tcommit_graft_nr++;\n \tif (pos < commit_graft_nr)\n \t\tmemmove(commit_graft + pos + 1,\n \t\t\tcommit_graft + pos,\n-- \n1.8.5.3\n"},{"id":"235575","messageId":"53105A37.5060603@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 05/11] diff.c: use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:43:19Z","receivedAt":"2014-02-28T09:43:19Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n diff.c | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e800666..aebdfda 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n {\n \tstruct diffstat_file *x;\n \tx = xcalloc(sizeof (*x), 1);\n-\tif (diffstat->nr == diffstat->alloc) {\n-\t\tdiffstat->alloc = alloc_nr(diffstat->alloc);\n-\t\tdiffstat->files = xrealloc(diffstat->files,\n-\t\t\t\tdiffstat->alloc * sizeof(x));\n-\t}\n+\tALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);\n \tdiffstat->files[diffstat->nr++] = x;\n \tif (name_b) {\n \t\tx->from_name = xstrdup(name_a);\n@@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n {\n-\tif (queue->alloc <= queue->nr) {\n-\t\tqueue->alloc = alloc_nr(queue->alloc);\n-\t\tqueue->queue = xrealloc(queue->queue,\n-\t\t\t\t\tsizeof(dp) * queue->alloc);\n-\t}\n+\tALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);\n \tqueue->queue[queue->nr++] = dp;\n }\n \n-- \n1.8.5.3\n"},{"id":"235576","messageId":"53105A6A.30200@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 06/11] diffcore-rename.c: use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:44:10Z","receivedAt":"2014-02-28T09:44:10Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Affected functions: locate_rename_dst(), register_rename_src()\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n diffcore-rename.c | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 9b4f068..fbf3272 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,\n \tif (!insert_ok)\n \t\treturn NULL;\n \t/* insert to make it at \"first\" */\n-\tif (rename_dst_alloc <= rename_dst_nr) {\n-\t\trename_dst_alloc = alloc_nr(rename_dst_alloc);\n-\t\trename_dst = xrealloc(rename_dst,\n-\t\t\t\t      rename_dst_alloc * sizeof(*rename_dst));\n-\t}\n+\tALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);\n \trename_dst_nr++;\n \tif (first < rename_dst_nr)\n \t\tmemmove(rename_dst + first + 1, rename_dst + first,\n@@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)\n \t}\n \n \t/* insert to make it at \"first\" */\n-\tif (rename_src_alloc <= rename_src_nr) {\n-\t\trename_src_alloc = alloc_nr(rename_src_alloc);\n-\t\trename_src = xrealloc(rename_src,\n-\t\t\t\t      rename_src_alloc * sizeof(*rename_src));\n-\t}\n+\tALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);\n \trename_src_nr++;\n \tif (first < rename_src_nr)\n \t\tmemmove(rename_src + first + 1, rename_src + first,\n-- \n1.8.5.3\n"},{"id":"235577","messageId":"53105A9D.9040400@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 07/11] patch-ids.c: change add_commit() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:45:01Z","receivedAt":"2014-02-28T09:45:01Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n patch-ids.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/patch-ids.c b/patch-ids.c\nindex bc8a28f..bf81b92 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -83,10 +83,7 @@ static struct patch_id *add_commit(struct commit *commit,\n \tent = &bucket->bucket[bucket->nr++];\n \thashcpy(ent->patch_id, sha1);\n \n-\tif (ids->alloc <= ids->nr) {\n-\t\tids->alloc = alloc_nr(ids->nr);\n-\t\tids->table = xrealloc(ids->table, sizeof(ent) * ids->alloc);\n-\t}\n+\tALLOC_GROW(ids->table, ids->nr + 1, ids->alloc);\n \tif (pos < ids->nr)\n \t\tmemmove(ids->table + pos + 1, ids->table + pos,\n \t\t\tsizeof(ent) * (ids->nr - pos));\n-- \n1.8.5.3\n"},{"id":"235578","messageId":"53105AC5.8000607@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 08/11] replace_object.c: change register_replace_object() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:45:41Z","receivedAt":"2014-02-28T09:45:41Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n replace_object.c | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/replace_object.c b/replace_object.c\nindex cdcaf8c..843deef 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -36,12 +36,8 @@ static int register_replace_object(struct replace_object *replace,\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (replace_object_alloc <= ++replace_object_nr) {\n-\t\treplace_object_alloc = alloc_nr(replace_object_alloc);\n-\t\treplace_object = xrealloc(replace_object,\n-\t\t\t\t\t  sizeof(*replace_object) *\n-\t\t\t\t\t  replace_object_alloc);\n-\t}\n+\tALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);\n+\treplace_object_nr++;\n \tif (pos < replace_object_nr)\n \t\tmemmove(replace_object + pos + 1,\n \t\t\treplace_object + pos,\n-- \n1.8.5.3\n"},{"id":"235580","messageId":"53105AF2.3070301@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 09/11] reflog-walk.c: use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:46:26Z","receivedAt":"2014-02-28T09:46:26Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Affected functions: read_one_reflog(), add_commit_info()\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n reflog-walk.c | 13 +++----------\n 1 file changed, 3 insertions(+), 10 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex b2fbdb2..879d2ed 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,\n \tstruct complete_reflogs *array = cb_data;\n \tstruct reflog_info *item;\n \n-\tif (array->nr >= array->alloc) {\n-\t\tarray->alloc = alloc_nr(array->nr + 1);\n-\t\tarray->items = xrealloc(array->items, array->alloc *\n-\t\t\tsizeof(struct reflog_info));\n-\t}\n+\tALLOC_GROW(array->items, array->nr + 1, array->alloc);\n \titem = array->items + array->nr;\n \tmemcpy(item->osha1, osha1, 20);\n \tmemcpy(item->nsha1, nsha1, 20);\n@@ -114,11 +110,8 @@ static void add_commit_info(struct commit *commit, void *util,\n \t\tstruct commit_info_lifo *lifo)\n {\n \tstruct commit_info *info;\n-\tif (lifo->nr >= lifo->alloc) {\n-\t\tlifo->alloc = alloc_nr(lifo->nr + 1);\n-\t\tlifo->items = xrealloc(lifo->items,\n-\t\t\tlifo->alloc * sizeof(struct commit_info));\n-\t}\n+\n+\tALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);\n \tinfo = lifo->items + lifo->nr;\n \tinfo->commit = commit;\n \tinfo->util = util;\n-- \n1.8.5.3\n"},{"id":"235581","messageId":"53105B0D.2090407@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 10/11] dir.c: change create_simplify() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:46:53Z","receivedAt":"2014-02-28T09:46:53Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n dir.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 98bb50f..4ae38e4 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1341,10 +1341,7 @@ static struct path_simplify *create_simplify(const char **pathspec)\n \n \tfor (nr = 0 ; ; nr++) {\n \t\tconst char *match;\n-\t\tif (nr >= alloc) {\n-\t\t\talloc = alloc_nr(alloc);\n-\t\t\tsimplify = xrealloc(simplify, alloc * sizeof(*simplify));\n-\t\t}\n+\t\tALLOC_GROW(simplify, nr + 1, alloc);\n \t\tmatch = *pathspec++;\n \t\tif (!match)\n \t\t\tbreak;\n-- \n1.8.5.3\n"},{"id":"235582","messageId":"53105B30.7010608@yandex.ru","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"[PATCH v2 11/11] attr.c: change handle_attr_line() to use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-02-28T09:47:28Z","receivedAt":"2014-02-28T09:47:28Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n attr.c | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 8d13d70..734222d 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,\n \ta = parse_attr_line(line, src, lineno, macro_ok);\n \tif (!a)\n \t\treturn;\n-\tif (res->alloc <= res->num_matches) {\n-\t\tres->alloc = alloc_nr(res->num_matches);\n-\t\tres->attrs = xrealloc(res->attrs,\n-\t\t\t\t      sizeof(struct match_attr *) *\n-\t\t\t\t      res->alloc);\n-\t}\n+\tALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);\n \tres->attrs[res->num_matches++] = a;\n }\n \n-- \n1.8.5.3\n"},{"id":"235599","messageId":"CACsJy8C2h13JFqh=CKvR=3TByHkxWCNR-XhK-WxA+DOE3GmvAQ@mail.gmail.com","threadId":"35982","inReplyTo":"53105995.3010001@yandex.ru","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-28T12:32:16Z","receivedAt":"2014-02-28T12:32:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 28, 2014 at 4:40 PM, Dmitry S. Dolzhenko\n<dmitrys.dolzhenko@yandex.ru> wrote:\n> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n> ---\n>  builtin/pack-objects.c | 7 +------\n>  1 file changed, 1 insertion(+), 6 deletions(-)\n>\n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> index c733379..56a6fc8 100644\n> --- a/builtin/pack-objects.c\n> +++ b/builtin/pack-objects.c\n> @@ -1213,12 +1213,7 @@ static int check_pbase_path(unsigned hash)\n>         if (0 <= pos)\n>                 return 1;\n>         pos = -pos - 1;\n> -       if (done_pbase_paths_alloc <= done_pbase_paths_num) {\n> -               done_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n> -               done_pbase_paths = xrealloc(done_pbase_paths,\n> -                                           done_pbase_paths_alloc *\n> -                                           sizeof(unsigned));\n> -       }\n> +       ALLOC_GROW(done_pbase_paths, done_pbase_paths_num + 1, done_pbase_paths_alloc);\n\nNot strictly a rule, but I usually try to keep it within 80 columns,\nunless the surrounding code already breaks it.\n\n>         done_pbase_paths_num++;\n\nIf you move this up one line, then you don't have to \"+ 1\" in ALLOC_GROW\n\n>         if (pos < done_pbase_paths_num)\n>                 memmove(done_pbase_paths + pos + 1,\n> --\n> 1.8.5.3\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n\n\n-- \nDuy\n"},{"id":"235600","messageId":"CACsJy8DKXYJc2k6Zsqd0ruF_Jex=FH8rWzmhax2Co8z_oa+7zw@mail.gmail.com","threadId":"35982","inReplyTo":"53105AF2.3070301@yandex.ru","subject":"Re: [PATCH v2 09/11] reflog-walk.c: use ALLOC_GROW() instead of inline code","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-28T12:39:12Z","receivedAt":"2014-02-28T12:39:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 28, 2014 at 4:46 PM, Dmitry S. Dolzhenko\n<dmitrys.dolzhenko@yandex.ru> wrote:\n> Affected functions: read_one_reflog(), add_commit_info()\n\nWe can usually see this from @@ line so it's not really needed to\ndescribe. Same comment for a few other patches.\n-- \nDuy\n"},{"id":"235601","messageId":"CACsJy8AmQeVb-i6Sn0BH-_ikEXPHTdtKnQRyzChX1WfD9Lj4Jw@mail.gmail.com","threadId":"35982","inReplyTo":"CACsJy8C2h13JFqh=CKvR=3TByHkxWCNR-XhK-WxA+DOE3GmvAQ@mail.gmail.com","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-28T12:40:19Z","receivedAt":"2014-02-28T12:40:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 28, 2014 at 7:32 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>>         done_pbase_paths_num++;\n>\n> If you move this up one line, then you don't have to \"+ 1\" in ALLOC_GROW\n>\n\nsame comment to a few other patches. The rest of your series looks good.\n-- \nDuy\n"},{"id":"235614","messageId":"53109B19.8070103@alum.mit.edu","threadId":"35982","inReplyTo":"CACsJy8AmQeVb-i6Sn0BH-_ikEXPHTdtKnQRyzChX1WfD9Lj4Jw@mail.gmail.com","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-28T14:20:09Z","receivedAt":"2014-02-28T14:20:09Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/28/2014 01:40 PM, Duy Nguyen wrote:\n> On Fri, Feb 28, 2014 at 7:32 PM, Duy Nguyen <pclouds@gmail.com> wrote:\n>>>         done_pbase_paths_num++;\n>>\n>> If you move this up one line, then you don't have to \"+ 1\" in ALLOC_GROW\n>>\n> \n> same comment to a few other patches. The rest of your series looks good.\n\nDuy,\n\nThe example in Documentation/technical/api-allocation-growing.txt does\nit the same way as Dmitry:\n\n    ALLOC_GROW(item, nr + 1, alloc);\n    item[nr++] = value you like;\n\nThe alternative,\n\n    nr++;\n    ALLOC_GROW(item, nr, alloc);\n    item[nr] = value you like;\n\nis an extra line, which is at least a small argument for the variant\nshown in the docs.  (Since ALLOC_GROW is a macro, it is not OK to use\n\"++nr\" as its second argument.)  Personally, I also prefer the shorter\nversion.  The line\n\n    item[nr++] = value\n\nis an easy-to-recognize idiom, and\n\n    ALLOC_GROW(item, nr + 1, alloc);\n\nsomehow makes it more transparent by how much more space will be needed.\n\nSo my vote is that the patches are OK the way Dmitry wrote them (mind, I\nhave only read through 05/11 so far).\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"235619","messageId":"CACsJy8C1Jv-7Fz=qTZ94vZCVD6s39iju2BRZdhnkSR25VoJ=Ow@mail.gmail.com","threadId":"35982","inReplyTo":"53109B19.8070103@alum.mit.edu","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-02-28T14:36:49Z","receivedAt":"2014-02-28T14:36:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Feb 28, 2014 at 9:20 PM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> Duy,\n>\n> The example in Documentation/technical/api-allocation-growing.txt does\n> it the same way as Dmitry:\n>\n>     ALLOC_GROW(item, nr + 1, alloc);\n>     item[nr++] = value you like;\n>\n> The alternative,\n>\n>     nr++;\n>     ALLOC_GROW(item, nr, alloc);\n>     item[nr] = value you like;\n>\n> is an extra line, which is at least a small argument for the variant\n> shown in the docs.  (Since ALLOC_GROW is a macro, it is not OK to use\n> \"++nr\" as its second argument.)  Personally, I also prefer the shorter\n> version.  The line\n>\n>     item[nr++] = value\n>\n> is an easy-to-recognize idiom, and\n>\n>     ALLOC_GROW(item, nr + 1, alloc);\n>\n> somehow makes it more transparent by how much more space will be needed.\n>\n> So my vote is that the patches are OK the way Dmitry wrote them (mind, I\n> have only read through 05/11 so far).\n\nI'm not saying all patches should do\n\nnr++;\nALLOC_GROW(item, nr, alloc);\n\nonly those that do\n\nif (..) realloc...;\nnr++;\n....\n\nshould be reordered. Those changes that do item[nr++] = yyy should be\nkept. Anyway it's just an observation, not something that should block\nthese patches.\n-- \nDuy\n"},{"id":"235622","messageId":"53109F78.2060203@alum.mit.edu","threadId":"35982","inReplyTo":"531056E7.3010305@yandex.ru","subject":"Re: [PATCH v2 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2014-02-28T14:38:48Z","receivedAt":"2014-02-28T14:38:48Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 02/28/2014 10:29 AM, Dmitry S. Dolzhenko wrote:\n> Thank you for your remarks. In this patch I tried to take them into account.\n> \n> Dmitry S. Dolzhenko (11):\n>   builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()\n>   bundle.c: change add_to_ref_list() to use ALLOC_GROW()\n>   cache-tree.c: change find_subtree() to use ALLOC_GROW()\n>   commit.c: change register_commit_graft() to use ALLOC_GROW()\n>   diff.c: use ALLOC_GROW() instead of inline code\n>   diffcore-rename.c: use ALLOC_GROW() instead of inline code\n>   patch-ids.c: change add_commit() to use ALLOC_GROW()\n>   replace_object.c: change register_replace_object() to use ALLOC_GROW()\n>   reflog-walk.c: use ALLOC_GROW() instead of inline code\n>   dir.c: change create_simplify() to use ALLOC_GROW()\n>   attr.c: change handle_attr_line() to use ALLOC_GROW()\n> \n>  attr.c                 |  7 +------\n>  builtin/pack-objects.c |  7 +------\n>  bundle.c               |  6 +-----\n>  cache-tree.c           |  6 +-----\n>  commit.c               |  8 ++------\n>  diff.c                 | 12 ++----------\n>  diffcore-rename.c      | 12 ++----------\n>  dir.c                  |  5 +----\n>  patch-ids.c            |  5 +----\n>  reflog-walk.c          | 13 +++----------\n>  replace_object.c       |  8 ++------\n>  11 files changed, 17 insertions(+), 72 deletions(-)\n\nEverything looks fine to me.  Assuming the test suite ran 100%,\n\nAcked-by: Michael Haggerty <mhagger@alum.mit.edu>\n\nThanks!\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"235655","messageId":"xmqqfvn3ukjs.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"53109B19.8070103@alum.mit.edu","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-28T19:03:19Z","receivedAt":"2014-02-28T19:03:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> So my vote is that the patches are OK the way Dmitry wrote them (mind, I\n> have only read through 05/11 so far).\n\nSeconded ;-)\n\nBy the way, I do not like these long subjects.  \"change\" is a\nredundant word when one sends a patch---as all patches are about\nchanging something.\n\n\tSubject: builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n\nwould be a lot more appropriate for \"git shortlog\" consumption.\n"},{"id":"235656","messageId":"xmqqbnxrukdw.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"CACsJy8DKXYJc2k6Zsqd0ruF_Jex=FH8rWzmhax2Co8z_oa+7zw@mail.gmail.com","subject":"Re: [PATCH v2 09/11] reflog-walk.c: use ALLOC_GROW() instead of inline code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-02-28T19:06:51Z","receivedAt":"2014-02-28T19:06:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Fri, Feb 28, 2014 at 4:46 PM, Dmitry S. Dolzhenko\n> <dmitrys.dolzhenko@yandex.ru> wrote:\n>> Affected functions: read_one_reflog(), add_commit_info()\n>\n> We can usually see this from @@ line so it's not really needed to\n> describe. Same comment for a few other patches.\n\nNot everybody always reads \"git log\" with \"-p\".  It is good to see\nwhat are changed mentioned somewhere.\n\nI prefer to see full sentences, though ;-)\n\n\tSubject: reflog-walk.c: use ALLOC_GROW()\n\n\tread_one_reflog() and add_commit_info() open-codes reallocation;\n        use ALLOC_GROW() instead.\n\nor something.  But that is minor.\n"},{"id":"235699","messageId":"531184E0.3000808@yandex.ru","threadId":"35982","inReplyTo":"53109F78.2060203@alum.mit.edu","subject":"Re: [PATCH v2 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-01T06:57:36Z","receivedAt":"2014-03-01T06:57:36Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Michael,\n\nOn 28.02.2014 18:38, Michael Haggerty wrote:\n> Everything looks fine to me.  Assuming the test suite ran 100%,\n> \n> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>\n\nAll tests passed successfully for this patch, at least on my machine.\nCan I do something else to improve this patch?\n"},{"id":"235700","messageId":"20140301070758.GE20397@sigill.intra.peff.net","threadId":"35982","inReplyTo":"xmqqfvn3ukjs.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-03-01T07:07:58Z","receivedAt":"2014-03-01T07:07:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 28, 2014 at 11:03:19AM -0800, Junio C Hamano wrote:\n\n> Michael Haggerty <mhagger@alum.mit.edu> writes:\n> \n> > So my vote is that the patches are OK the way Dmitry wrote them (mind, I\n> > have only read through 05/11 so far).\n> \n> Seconded ;-)\n> \n> By the way, I do not like these long subjects.  \"change\" is a\n> redundant word when one sends a patch---as all patches are about\n> changing something.\n> \n> \tSubject: builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n> \n> would be a lot more appropriate for \"git shortlog\" consumption.\n\nI would actually go one step further and drop or shorten the filename in\nthe subject. It is very long, it is already easy to see which file was\nchanged from the diffstat, and it doesn't give any useful context for\nother parts of the subject.\n\nI really like the \"foo:\" convention for starting a subject line, because\nit immediately makes clear what area you are working in without having\nto waste space on English conjunctions or prepositions. But it does not\nhave to be a filename. It can be a subsystem, a command, a function, an\narea of the project, or anything that gives context to the rest of the\nline.\n\nSo I would suggest one of:\n\n  Subject: use ALLOC_GROW() in check_pbase_path()\n\n    Talking about the filename is redundant; there's only one\n    check_pbase_path.\n\n  Subject: check_pbase_path: use ALLOW_GROW\n\n    Even shorter.\n\n  Subject: builtin/pack-objects.c: use ALLOC_GROW\n\n    This one implies to me that the point of the commit is to convert\n    the whole file to use ALLOC_GROW where appropriate, not just that\n    function (even if that function may be the only spot changed).\n\nI'd probably not use:\n\n  Subject: pack-objects: use ALLOC_GROW\n\nas the scope is not about the command, but about the C file.\n\nI realize that I just bikeshedded on subject lines for half a page, and\npart of me wants to go kill myself in shame. But I feel like I see the\ntechnique misapplied often enough that maybe some guidance is merited.\nFeel free to ignore. :)\n\n-Peff\n"},{"id":"235829","messageId":"53142CB9.80100@yandex.ru","threadId":"35982","inReplyTo":"530FA3E7.8020200@yandex.ru","subject":"[PATCH v3 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:18:17Z","receivedAt":"2014-03-03T07:18:17Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Dmitry S. Dolzhenko (11):\n  builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n  bundle.c: use ALLOC_GROW() in add_to_ref_list()\n  cache-tree.c: use ALLOC_GROW() in find_subtree()\n  commit.c: use ALLOC_GROW() in register_commit_graft()\n  diff.c: use ALLOC_GROW()\n  diffcore-rename.c: use ALLOC_GROW()\n  patch-ids.c: use ALLOC_GROW() in add_commit()\n  replace_object.c: use ALLOC_GROW() in register_replace_object()\n  reflog-walk.c: use ALLOC_GROW()\n  dir.c: use ALLOC_GROW() in create_simplify()\n  attr.c: use ALLOC_GROW() in handle_attr_line()\n\n attr.c                 |  7 +------\n builtin/pack-objects.c |  9 +++------\n bundle.c               |  6 +-----\n cache-tree.c           |  6 +-----\n commit.c               |  8 ++------\n diff.c                 | 12 ++----------\n diffcore-rename.c      | 12 ++----------\n dir.c                  |  5 +----\n patch-ids.c            |  5 +----\n reflog-walk.c          | 12 ++----------\n replace_object.c       |  8 ++------\n 11 files changed, 18 insertions(+), 72 deletions(-)\n\n-- \n1.8.5.3\n\nThis version differs from previous only minor changes:\n  - update commit messages\n  - keep code lines within 80 columns\n"},{"id":"235830","messageId":"53142D08.4060108@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 01/11] builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:19:36Z","receivedAt":"2014-03-03T07:19:36Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n builtin/pack-objects.c | 9 +++------\n 1 file changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex c733379..0ffad6f 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1213,12 +1213,9 @@ static int check_pbase_path(unsigned hash)\n \tif (0 <= pos)\n \t\treturn 1;\n \tpos = -pos - 1;\n-\tif (done_pbase_paths_alloc <= done_pbase_paths_num) {\n-\t\tdone_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n-\t\tdone_pbase_paths = xrealloc(done_pbase_paths,\n-\t\t\t\t\t    done_pbase_paths_alloc *\n-\t\t\t\t\t    sizeof(unsigned));\n-\t}\n+\tALLOC_GROW(done_pbase_paths,\n+\t\t   done_pbase_paths_num + 1,\n+\t\t   done_pbase_paths_alloc);\n \tdone_pbase_paths_num++;\n \tif (pos < done_pbase_paths_num)\n \t\tmemmove(done_pbase_paths + pos + 1,\n-- \n1.8.5.3\n"},{"id":"235831","messageId":"53142D23.6000505@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 02/11] bundle.c: use ALLOC_GROW() in add_to_ref_list()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:20:03Z","receivedAt":"2014-03-03T07:20:03Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n bundle.c | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex e99065c..1388a3e 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n static void add_to_ref_list(const unsigned char *sha1, const char *name,\n \t\tstruct ref_list *list)\n {\n-\tif (list->nr + 1 >= list->alloc) {\n-\t\tlist->alloc = alloc_nr(list->nr + 1);\n-\t\tlist->list = xrealloc(list->list,\n-\t\t\t\tlist->alloc * sizeof(list->list[0]));\n-\t}\n+\tALLOC_GROW(list->list, list->nr + 1, list->alloc);\n \tmemcpy(list->list[list->nr].sha1, sha1, 20);\n \tlist->list[list->nr].name = xstrdup(name);\n \tlist->nr++;\n-- \n1.8.5.3\n"},{"id":"235832","messageId":"53142D45.6050601@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 03/11] cache-tree.c: use ALLOC_GROW() in find_subtree()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:20:37Z","receivedAt":"2014-03-03T07:20:37Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n cache-tree.c | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 0bbec43..30149d1 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,\n \t\treturn NULL;\n \n \tpos = -pos-1;\n-\tif (it->subtree_alloc <= it->subtree_nr) {\n-\t\tit->subtree_alloc = alloc_nr(it->subtree_alloc);\n-\t\tit->down = xrealloc(it->down, it->subtree_alloc *\n-\t\t\t\t    sizeof(*it->down));\n-\t}\n+\tALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);\n \tit->subtree_nr++;\n \n \tdown = xmalloc(sizeof(*down) + pathlen + 1);\n-- \n1.8.5.3\n"},{"id":"235833","messageId":"53142D70.30704@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 04/11] commit.c: use ALLOC_GROW() in register_commit_graft()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:21:20Z","receivedAt":"2014-03-03T07:21:20Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n commit.c | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/commit.c b/commit.c\nindex 6bf4fe0..e004314 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (commit_graft_alloc <= ++commit_graft_nr) {\n-\t\tcommit_graft_alloc = alloc_nr(commit_graft_alloc);\n-\t\tcommit_graft = xrealloc(commit_graft,\n-\t\t\t\t\tsizeof(*commit_graft) *\n-\t\t\t\t\tcommit_graft_alloc);\n-\t}\n+\tALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n+\tcommit_graft_nr++;\n \tif (pos < commit_graft_nr)\n \t\tmemmove(commit_graft + pos + 1,\n \t\t\tcommit_graft + pos,\n-- \n1.8.5.3\n"},{"id":"235834","messageId":"53142D9A.40707@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 05/11] diff.c: use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:22:02Z","receivedAt":"2014-03-03T07:22:02Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Use ALLOC_GROW() instead inline code in\ndiffstat_add() and diff_q()\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n diff.c | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e800666..aebdfda 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n {\n \tstruct diffstat_file *x;\n \tx = xcalloc(sizeof (*x), 1);\n-\tif (diffstat->nr == diffstat->alloc) {\n-\t\tdiffstat->alloc = alloc_nr(diffstat->alloc);\n-\t\tdiffstat->files = xrealloc(diffstat->files,\n-\t\t\t\tdiffstat->alloc * sizeof(x));\n-\t}\n+\tALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);\n \tdiffstat->files[diffstat->nr++] = x;\n \tif (name_b) {\n \t\tx->from_name = xstrdup(name_a);\n@@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;\n \n void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n {\n-\tif (queue->alloc <= queue->nr) {\n-\t\tqueue->alloc = alloc_nr(queue->alloc);\n-\t\tqueue->queue = xrealloc(queue->queue,\n-\t\t\t\t\tsizeof(dp) * queue->alloc);\n-\t}\n+\tALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);\n \tqueue->queue[queue->nr++] = dp;\n }\n \n-- \n1.8.5.3\n"},{"id":"235835","messageId":"53142DC0.1080403@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 06/11] diffcore-rename.c: use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:22:40Z","receivedAt":"2014-03-03T07:22:40Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Use ALLOC_GROW() instead inline code in\nlocate_rename_dst() and register_rename_src()\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n diffcore-rename.c | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/diffcore-rename.c b/diffcore-rename.c\nindex 9b4f068..fbf3272 100644\n--- a/diffcore-rename.c\n+++ b/diffcore-rename.c\n@@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,\n \tif (!insert_ok)\n \t\treturn NULL;\n \t/* insert to make it at \"first\" */\n-\tif (rename_dst_alloc <= rename_dst_nr) {\n-\t\trename_dst_alloc = alloc_nr(rename_dst_alloc);\n-\t\trename_dst = xrealloc(rename_dst,\n-\t\t\t\t      rename_dst_alloc * sizeof(*rename_dst));\n-\t}\n+\tALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);\n \trename_dst_nr++;\n \tif (first < rename_dst_nr)\n \t\tmemmove(rename_dst + first + 1, rename_dst + first,\n@@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)\n \t}\n \n \t/* insert to make it at \"first\" */\n-\tif (rename_src_alloc <= rename_src_nr) {\n-\t\trename_src_alloc = alloc_nr(rename_src_alloc);\n-\t\trename_src = xrealloc(rename_src,\n-\t\t\t\t      rename_src_alloc * sizeof(*rename_src));\n-\t}\n+\tALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);\n \trename_src_nr++;\n \tif (first < rename_src_nr)\n \t\tmemmove(rename_src + first + 1, rename_src + first,\n-- \n1.8.5.3\n"},{"id":"235836","messageId":"53142DDB.40600@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 07/11] patch-ids.c: use ALLOC_GROW() in add_commit()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:23:07Z","receivedAt":"2014-03-03T07:23:07Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n patch-ids.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/patch-ids.c b/patch-ids.c\nindex bc8a28f..bf81b92 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -83,10 +83,7 @@ static struct patch_id *add_commit(struct commit *commit,\n \tent = &bucket->bucket[bucket->nr++];\n \thashcpy(ent->patch_id, sha1);\n \n-\tif (ids->alloc <= ids->nr) {\n-\t\tids->alloc = alloc_nr(ids->nr);\n-\t\tids->table = xrealloc(ids->table, sizeof(ent) * ids->alloc);\n-\t}\n+\tALLOC_GROW(ids->table, ids->nr + 1, ids->alloc);\n \tif (pos < ids->nr)\n \t\tmemmove(ids->table + pos + 1, ids->table + pos,\n \t\t\tsizeof(ent) * (ids->nr - pos));\n-- \n1.8.5.3\n"},{"id":"235837","messageId":"53142E07.9000409@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 08/11] replace_object.c: use ALLOC_GROW() in register_replace_object()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:23:51Z","receivedAt":"2014-03-03T07:23:51Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n replace_object.c | 8 ++------\n 1 file changed, 2 insertions(+), 6 deletions(-)\n\ndiff --git a/replace_object.c b/replace_object.c\nindex cdcaf8c..843deef 100644\n--- a/replace_object.c\n+++ b/replace_object.c\n@@ -36,12 +36,8 @@ static int register_replace_object(struct replace_object *replace,\n \t\treturn 1;\n \t}\n \tpos = -pos - 1;\n-\tif (replace_object_alloc <= ++replace_object_nr) {\n-\t\treplace_object_alloc = alloc_nr(replace_object_alloc);\n-\t\treplace_object = xrealloc(replace_object,\n-\t\t\t\t\t  sizeof(*replace_object) *\n-\t\t\t\t\t  replace_object_alloc);\n-\t}\n+\tALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);\n+\treplace_object_nr++;\n \tif (pos < replace_object_nr)\n \t\tmemmove(replace_object + pos + 1,\n \t\t\treplace_object + pos,\n-- \n1.8.5.3\n"},{"id":"235838","messageId":"53142E33.6030303@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 09/11] reflog-walk.c: use ALLOC_GROW()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:24:35Z","receivedAt":"2014-03-03T07:24:35Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Use ALLOC_GROW() instead inline code in\nadd_commit_info() and read_one_reflog()\n\nSigned-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n reflog-walk.c | 12 ++----------\n 1 file changed, 2 insertions(+), 10 deletions(-)\n\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex b2fbdb2..2899729 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,\n \tstruct complete_reflogs *array = cb_data;\n \tstruct reflog_info *item;\n \n-\tif (array->nr >= array->alloc) {\n-\t\tarray->alloc = alloc_nr(array->nr + 1);\n-\t\tarray->items = xrealloc(array->items, array->alloc *\n-\t\t\tsizeof(struct reflog_info));\n-\t}\n+\tALLOC_GROW(array->items, array->nr + 1, array->alloc);\n \titem = array->items + array->nr;\n \tmemcpy(item->osha1, osha1, 20);\n \tmemcpy(item->nsha1, nsha1, 20);\n@@ -114,11 +110,7 @@ static void add_commit_info(struct commit *commit, void *util,\n \t\tstruct commit_info_lifo *lifo)\n {\n \tstruct commit_info *info;\n-\tif (lifo->nr >= lifo->alloc) {\n-\t\tlifo->alloc = alloc_nr(lifo->nr + 1);\n-\t\tlifo->items = xrealloc(lifo->items,\n-\t\t\tlifo->alloc * sizeof(struct commit_info));\n-\t}\n+\tALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);\n \tinfo = lifo->items + lifo->nr;\n \tinfo->commit = commit;\n \tinfo->util = util;\n-- \n1.8.5.3\n"},{"id":"235839","messageId":"53142E6B.6030602@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 10/11] dir.c: use ALLOC_GROW() in create_simplify()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:25:31Z","receivedAt":"2014-03-03T07:25:31Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n dir.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/dir.c b/dir.c\nindex 98bb50f..4ae38e4 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1341,10 +1341,7 @@ static struct path_simplify *create_simplify(const char **pathspec)\n \n \tfor (nr = 0 ; ; nr++) {\n \t\tconst char *match;\n-\t\tif (nr >= alloc) {\n-\t\t\talloc = alloc_nr(alloc);\n-\t\t\tsimplify = xrealloc(simplify, alloc * sizeof(*simplify));\n-\t\t}\n+\t\tALLOC_GROW(simplify, nr + 1, alloc);\n \t\tmatch = *pathspec++;\n \t\tif (!match)\n \t\t\tbreak;\n-- \n1.8.5.3\n"},{"id":"235840","messageId":"53142E82.5080806@yandex.ru","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"[PATCH v3 11/11] attr.c: use ALLOC_GROW() in handle_attr_line()","fromName":"Dmitry S. Dolzhenko","fromEmail":"dmitrys.dolzhenko@yandex.ru","sentAt":"2014-03-03T07:25:54Z","receivedAt":"2014-03-03T07:25:54Z","isPatch":true,"sender":{"key":"dmitrys.dolzhenko@yandex.ru","avatar":null},"body":"Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>\n---\n attr.c | 7 +------\n 1 file changed, 1 insertion(+), 6 deletions(-)\n\ndiff --git a/attr.c b/attr.c\nindex 8d13d70..734222d 100644\n--- a/attr.c\n+++ b/attr.c\n@@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,\n \ta = parse_attr_line(line, src, lineno, macro_ok);\n \tif (!a)\n \t\treturn;\n-\tif (res->alloc <= res->num_matches) {\n-\t\tres->alloc = alloc_nr(res->num_matches);\n-\t\tres->attrs = xrealloc(res->attrs,\n-\t\t\t\t      sizeof(struct match_attr *) *\n-\t\t\t\t      res->alloc);\n-\t}\n+\tALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);\n \tres->attrs[res->num_matches++] = a;\n }\n \n-- \n1.8.5.3\n"},{"id":"235847","messageId":"CAPig+cQ-6h3JJr5uUu0J1_m+ENfFq2X4CusetPssQuJNB61zCA@mail.gmail.com","threadId":"35982","inReplyTo":"53142CB9.80100@yandex.ru","subject":"Re: [PATCH v3 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-03T08:23:31Z","receivedAt":"2014-03-03T08:23:31Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Mar 3, 2014 at 2:18 AM, Dmitry S. Dolzhenko\n<dmitrys.dolzhenko@yandex.ru> wrote:\n> Dmitry S. Dolzhenko (11):\n>   builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n>   bundle.c: use ALLOC_GROW() in add_to_ref_list()\n>   cache-tree.c: use ALLOC_GROW() in find_subtree()\n>   commit.c: use ALLOC_GROW() in register_commit_graft()\n>   diff.c: use ALLOC_GROW()\n>   diffcore-rename.c: use ALLOC_GROW()\n>   patch-ids.c: use ALLOC_GROW() in add_commit()\n>   replace_object.c: use ALLOC_GROW() in register_replace_object()\n>   reflog-walk.c: use ALLOC_GROW()\n>   dir.c: use ALLOC_GROW() in create_simplify()\n>   attr.c: use ALLOC_GROW() in handle_attr_line()\n>\n>  attr.c                 |  7 +------\n>  builtin/pack-objects.c |  9 +++------\n>  bundle.c               |  6 +-----\n>  cache-tree.c           |  6 +-----\n>  commit.c               |  8 ++------\n>  diff.c                 | 12 ++----------\n>  diffcore-rename.c      | 12 ++----------\n>  dir.c                  |  5 +----\n>  patch-ids.c            |  5 +----\n>  reflog-walk.c          | 12 ++----------\n>  replace_object.c       |  8 ++------\n>  11 files changed, 18 insertions(+), 72 deletions(-)\n>\n> --\n> 1.8.5.3\n>\n> This version differs from previous only minor changes:\n>   - update commit messages\n>   - keep code lines within 80 columns\n\nPlace this commentary at the top of the cover letter since that's\nwhere people look for it.\n\nYou want to ease the reviewer's job as much as possible, so it helps\nto link to the previous submission, like this [1].\n\nLikewise, you can help the reviewer by being more specific about how\nyou updated the commit messages (and perhaps by linking to the\nrelevant discussion points, like this [2][3]).\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/242857\n[2]: http://article.gmane.org/gmane.comp.version-control.git/243004\n[3]: http://article.gmane.org/gmane.comp.version-control.git/243049\n"},{"id":"235872","messageId":"CAJr59C0Fh5eqAqMwidB7EFq9u_ZLQ1=ZUyEEifhEb3ALUpr33w@mail.gmail.com","threadId":"35982","inReplyTo":"530FA3E7.8020200@yandex.ru","subject":"Re: [PATCH] Use ALLOC_GROW() instead of inline code","fromName":"He Sun","fromEmail":"sunheehnus@gmail.com","sentAt":"2014-03-03T14:20:58Z","receivedAt":"2014-03-03T14:20:58Z","isPatch":true,"sender":{"key":"sunheehnus@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2889804?v=4"},"body":"2014-02-28 4:45 GMT+08:00 Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex.ru>:\n> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@gmail.com>\n> ---\n>  attr.c                 |  7 +------\n>  builtin/pack-objects.c |  7 +------\n>  bundle.c               |  6 +-----\n>  cache-tree.c           |  6 +-----\n>  commit.c               |  8 ++------\n>  diff.c                 | 12 ++----------\n>  diffcore-rename.c      | 12 ++----------\n>  dir.c                  |  5 +----\n>  patch-ids.c            |  5 +----\n>  read-cache.c           |  9 ++-------\n>  reflog-walk.c          | 13 +++----------\n>  replace_object.c       |  8 ++------\n>  12 files changed, 19 insertions(+), 79 deletions(-)\n>\n\nI find another two files can be fixed this way.\n- builtin/mktree.c\n- sha1_file.c\n\nI find it by searching the key word \"alloc_nr\" throughout the source code.\nMay be there are other places of this kind of code and you can find it\nby other ways.\n\n> diff --git a/attr.c b/attr.c\n> index 8d13d70..734222d 100644\n> --- a/attr.c\n> +++ b/attr.c\n> @@ -338,12 +338,7 @@ static void handle_attr_line(struct attr_stack *res,\n>         a = parse_attr_line(line, src, lineno, macro_ok);\n>         if (!a)\n>                 return;\n> -       if (res->alloc <= res->num_matches) {\n> -               res->alloc = alloc_nr(res->num_matches);\n> -               res->attrs = xrealloc(res->attrs,\n> -                                     sizeof(struct match_attr *) *\n> -                                     res->alloc);\n> -       }\n> +       ALLOC_GROW(res->attrs, res->num_matches + 1, res->alloc);\n>         res->attrs[res->num_matches++] = a;\n>  }\n>\n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> index 541667f..92cbce8 100644\n> --- a/builtin/pack-objects.c\n> +++ b/builtin/pack-objects.c\n> @@ -1156,12 +1156,7 @@ static int check_pbase_path(unsigned hash)\n>         if (0 <= pos)\n>                 return 1;\n>         pos = -pos - 1;\n> -       if (done_pbase_paths_alloc <= done_pbase_paths_num) {\n> -               done_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);\n> -               done_pbase_paths = xrealloc(done_pbase_paths,\n> -                                           done_pbase_paths_alloc *\n> -                                           sizeof(unsigned));\n> -       }\n> +       ALLOC_GROW(done_pbase_paths, done_pbase_paths_num + 1, done_pbase_paths_alloc);\n>         done_pbase_paths_num++;\n>         if (pos < done_pbase_paths_num)\n>                 memmove(done_pbase_paths + pos + 1,\n> diff --git a/bundle.c b/bundle.c\n> index e99065c..1388a3e 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -14,11 +14,7 @@ static const char bundle_signature[] = \"# v2 git bundle\\n\";\n>  static void add_to_ref_list(const unsigned char *sha1, const char *name,\n>                 struct ref_list *list)\n>  {\n> -       if (list->nr + 1 >= list->alloc) {\n> -               list->alloc = alloc_nr(list->nr + 1);\n> -               list->list = xrealloc(list->list,\n> -                               list->alloc * sizeof(list->list[0]));\n> -       }\n> +       ALLOC_GROW(list->list, list->nr + 1, list->alloc);\n>         memcpy(list->list[list->nr].sha1, sha1, 20);\n>         list->list[list->nr].name = xstrdup(name);\n>         list->nr++;\n> diff --git a/cache-tree.c b/cache-tree.c\n> index 0bbec43..30149d1 100644\n> --- a/cache-tree.c\n> +++ b/cache-tree.c\n> @@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,\n>                 return NULL;\n>\n>         pos = -pos-1;\n> -       if (it->subtree_alloc <= it->subtree_nr) {\n> -               it->subtree_alloc = alloc_nr(it->subtree_alloc);\n> -               it->down = xrealloc(it->down, it->subtree_alloc *\n> -                                   sizeof(*it->down));\n> -       }\n> +       ALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);\n>         it->subtree_nr++;\n>\n>         down = xmalloc(sizeof(*down) + pathlen + 1);\n> diff --git a/commit.c b/commit.c\n> index 6bf4fe0..e004314 100644\n> --- a/commit.c\n> +++ b/commit.c\n> @@ -147,12 +147,8 @@ int register_commit_graft(struct commit_graft *graft, int ignore_dups)\n>                 return 1;\n>         }\n>         pos = -pos - 1;\n> -       if (commit_graft_alloc <= ++commit_graft_nr) {\n> -               commit_graft_alloc = alloc_nr(commit_graft_alloc);\n> -               commit_graft = xrealloc(commit_graft,\n> -                                       sizeof(*commit_graft) *\n> -                                       commit_graft_alloc);\n> -       }\n> +       ALLOC_GROW(commit_graft, commit_graft_nr + 1, commit_graft_alloc);\n> +       commit_graft_nr++;\n>         if (pos < commit_graft_nr)\n>                 memmove(commit_graft + pos + 1,\n>                         commit_graft + pos,\n> diff --git a/diff.c b/diff.c\n> index 8e4a6a9..f5f0fd1 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,\n>  {\n>         struct diffstat_file *x;\n>         x = xcalloc(sizeof (*x), 1);\n> -       if (diffstat->nr == diffstat->alloc) {\n> -               diffstat->alloc = alloc_nr(diffstat->alloc);\n> -               diffstat->files = xrealloc(diffstat->files,\n> -                               diffstat->alloc * sizeof(x));\n> -       }\n> +       ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);\n>         diffstat->files[diffstat->nr++] = x;\n>         if (name_b) {\n>                 x->from_name = xstrdup(name_a);\n> @@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;\n>\n>  void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)\n>  {\n> -       if (queue->alloc <= queue->nr) {\n> -               queue->alloc = alloc_nr(queue->alloc);\n> -               queue->queue = xrealloc(queue->queue,\n> -                                       sizeof(dp) * queue->alloc);\n> -       }\n> +       ALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);\n>         queue->queue[queue->nr++] = dp;\n>  }\n>\n> diff --git a/diffcore-rename.c b/diffcore-rename.c\n> index 6c7a72f..f54d5bf 100644\n> --- a/diffcore-rename.c\n> +++ b/diffcore-rename.c\n> @@ -38,11 +38,7 @@ static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,\n>         if (!insert_ok)\n>                 return NULL;\n>         /* insert to make it at \"first\" */\n> -       if (rename_dst_alloc <= rename_dst_nr) {\n> -               rename_dst_alloc = alloc_nr(rename_dst_alloc);\n> -               rename_dst = xrealloc(rename_dst,\n> -                                     rename_dst_alloc * sizeof(*rename_dst));\n> -       }\n> +       ALLOC_GROW(rename_dst, rename_dst_nr + 1, rename_dst_alloc);\n>         rename_dst_nr++;\n>         if (first < rename_dst_nr)\n>                 memmove(rename_dst + first + 1, rename_dst + first,\n> @@ -82,11 +78,7 @@ static struct diff_rename_src *register_rename_src(struct diff_filepair *p)\n>         }\n>\n>         /* insert to make it at \"first\" */\n> -       if (rename_src_alloc <= rename_src_nr) {\n> -               rename_src_alloc = alloc_nr(rename_src_alloc);\n> -               rename_src = xrealloc(rename_src,\n> -                                     rename_src_alloc * sizeof(*rename_src));\n> -       }\n> +       ALLOC_GROW(rename_src, rename_src_nr + 1, rename_src_alloc);\n>         rename_src_nr++;\n>         if (first < rename_src_nr)\n>                 memmove(rename_src + first + 1, rename_src + first,\n> diff --git a/dir.c b/dir.c\n> index b35b633..72f6e2a 100644\n> --- a/dir.c\n> +++ b/dir.c\n> @@ -1329,13 +1329,10 @@ static struct path_simplify *create_simplify(const char **pathspec)\n>\n>         for (nr = 0 ; ; nr++) {\n>                 const char *match;\n> -               if (nr >= alloc) {\n> -                       alloc = alloc_nr(alloc);\n> -                       simplify = xrealloc(simplify, alloc * sizeof(*simplify));\n> -               }\n>                 match = *pathspec++;\n>                 if (!match)\n>                         break;\n> +               ALLOC_GROW(simplify, nr + 1, alloc);\n>                 simplify[nr].path = match;\n>                 simplify[nr].len = simple_length(match);\n>         }\n> diff --git a/patch-ids.c b/patch-ids.c\n> index bc8a28f..bf81b92 100644\n> --- a/patch-ids.c\n> +++ b/patch-ids.c\n> @@ -83,10 +83,7 @@ static struct patch_id *add_commit(struct commit *commit,\n>         ent = &bucket->bucket[bucket->nr++];\n>         hashcpy(ent->patch_id, sha1);\n>\n> -       if (ids->alloc <= ids->nr) {\n> -               ids->alloc = alloc_nr(ids->nr);\n> -               ids->table = xrealloc(ids->table, sizeof(ent) * ids->alloc);\n> -       }\n> +       ALLOC_GROW(ids->table, ids->nr + 1, ids->alloc);\n>         if (pos < ids->nr)\n>                 memmove(ids->table + pos + 1, ids->table + pos,\n>                         sizeof(ent) * (ids->nr - pos));\n> diff --git a/read-cache.c b/read-cache.c\n> index 33dd676..e585541 100644\n> --- a/read-cache.c\n> +++ b/read-cache.c\n> @@ -993,11 +993,7 @@ int add_index_entry(struct index_state *istate, struct cache_entry *ce, int opti\n>         }\n>\n>         /* Make sure the array is big enough .. */\n> -       if (istate->cache_nr == istate->cache_alloc) {\n> -               istate->cache_alloc = alloc_nr(istate->cache_alloc);\n> -               istate->cache = xrealloc(istate->cache,\n> -                                       istate->cache_alloc * sizeof(*istate->cache));\n> -       }\n> +       ALLOC_GROW(istate->cache, istate->cache_nr + 1, istate->cache_alloc);\n>\n>         /* Add it in.. */\n>         istate->cache_nr++;\n> @@ -1466,8 +1462,7 @@ int read_index_from(struct index_state *istate, const char *path)\n>\n>         istate->version = ntohl(hdr->hdr_version);\n>         istate->cache_nr = ntohl(hdr->hdr_entries);\n> -       istate->cache_alloc = alloc_nr(istate->cache_nr);\n> -       istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));\n> +       ALLOC_GROW(istate->cache, istate->cache_nr, istate->cache_alloc);\n>         istate->initialized = 1;\n>\n>         if (istate->version == 4)\n> diff --git a/reflog-walk.c b/reflog-walk.c\n> index b2fbdb2..879d2ed 100644\n> --- a/reflog-walk.c\n> +++ b/reflog-walk.c\n> @@ -26,11 +26,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,\n>         struct complete_reflogs *array = cb_data;\n>         struct reflog_info *item;\n>\n> -       if (array->nr >= array->alloc) {\n> -               array->alloc = alloc_nr(array->nr + 1);\n> -               array->items = xrealloc(array->items, array->alloc *\n> -                       sizeof(struct reflog_info));\n> -       }\n> +       ALLOC_GROW(array->items, array->nr + 1, array->alloc);\n>         item = array->items + array->nr;\n>         memcpy(item->osha1, osha1, 20);\n>         memcpy(item->nsha1, nsha1, 20);\n> @@ -114,11 +110,8 @@ static void add_commit_info(struct commit *commit, void *util,\n>                 struct commit_info_lifo *lifo)\n>  {\n>         struct commit_info *info;\n> -       if (lifo->nr >= lifo->alloc) {\n> -               lifo->alloc = alloc_nr(lifo->nr + 1);\n> -               lifo->items = xrealloc(lifo->items,\n> -                       lifo->alloc * sizeof(struct commit_info));\n> -       }\n> +\n> +       ALLOC_GROW(lifo->items, lifo->nr + 1, lifo->alloc);\n>         info = lifo->items + lifo->nr;\n>         info->commit = commit;\n>         info->util = util;\n> diff --git a/replace_object.c b/replace_object.c\n> index cdcaf8c..843deef 100644\n> --- a/replace_object.c\n> +++ b/replace_object.c\n> @@ -36,12 +36,8 @@ static int register_replace_object(struct replace_object *replace,\n>                 return 1;\n>         }\n>         pos = -pos - 1;\n> -       if (replace_object_alloc <= ++replace_object_nr) {\n> -               replace_object_alloc = alloc_nr(replace_object_alloc);\n> -               replace_object = xrealloc(replace_object,\n> -                                         sizeof(*replace_object) *\n> -                                         replace_object_alloc);\n> -       }\n> +       ALLOC_GROW(replace_object, replace_object_nr + 1, replace_object_alloc);\n> +       replace_object_nr++;\n>         if (pos < replace_object_nr)\n>                 memmove(replace_object + pos + 1,\n>                         replace_object + pos,\n> --\n> 1.8.3.2\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nCheers,\nHe Sun\n"},{"id":"235894","messageId":"xmqqa9d7rvna.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"53109F78.2060203@alum.mit.edu","subject":"Re: [PATCH v2 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-03T18:20:57Z","receivedAt":"2014-03-03T18:20:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Haggerty <mhagger@alum.mit.edu> writes:\n\n> On 02/28/2014 10:29 AM, Dmitry S. Dolzhenko wrote:\n>> Thank you for your remarks. In this patch I tried to take them into account.\n>> \n>> Dmitry S. Dolzhenko (11):\n>>   builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()\n>>   bundle.c: change add_to_ref_list() to use ALLOC_GROW()\n>>   cache-tree.c: change find_subtree() to use ALLOC_GROW()\n>>   commit.c: change register_commit_graft() to use ALLOC_GROW()\n>>   diff.c: use ALLOC_GROW() instead of inline code\n>>   diffcore-rename.c: use ALLOC_GROW() instead of inline code\n>>   patch-ids.c: change add_commit() to use ALLOC_GROW()\n>>   replace_object.c: change register_replace_object() to use ALLOC_GROW()\n>>   reflog-walk.c: use ALLOC_GROW() instead of inline code\n>>   dir.c: change create_simplify() to use ALLOC_GROW()\n>>   attr.c: change handle_attr_line() to use ALLOC_GROW()\n>> \n>>  attr.c                 |  7 +------\n>>  builtin/pack-objects.c |  7 +------\n>>  bundle.c               |  6 +-----\n>>  cache-tree.c           |  6 +-----\n>>  commit.c               |  8 ++------\n>>  diff.c                 | 12 ++----------\n>>  diffcore-rename.c      | 12 ++----------\n>>  dir.c                  |  5 +----\n>>  patch-ids.c            |  5 +----\n>>  reflog-walk.c          | 13 +++----------\n>>  replace_object.c       |  8 ++------\n>>  11 files changed, 17 insertions(+), 72 deletions(-)\n>\n> Everything looks fine to me.  Assuming the test suite ran 100%,\n>\n> Acked-by: Michael Haggerty <mhagger@alum.mit.edu>\n\nLooked good (modulo titles, which I think we already discussed),\nand queued on 'pu'.\n\nThanks.\n"},{"id":"235895","messageId":"xmqq61nvrvir.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"20140301070758.GE20397@sigill.intra.peff.net","subject":"Re: [PATCH v2 01/11] builtin/pack-objects.c: change check_pbase_path() to use ALLOC_GROW()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-03T18:23:40Z","receivedAt":"2014-03-03T18:23:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> I realize that I just bikeshedded on subject lines for half a page, and\n> part of me wants to go kill myself in shame. But I feel like I see the\n> technique misapplied often enough that maybe some guidance is merited.\n\nThanks.  What I queued read like these:\n\n$ git shortlog ..dd/use-alloc-grow\n\nDmitry S. Dolzhenko (11):\n      builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n      bundle.c: use ALLOC_GROW() in add_to_ref_list()\n      cache-tree.c: use ALLOC_GROW() in find_subtree()\n      commit.c: use ALLOC_GROW() in register_commit_graft()\n      diff.c: use ALLOC_GROW() instead of inline code\n      diffcore-rename.c: use ALLOC_GROW() instead of inline code\n      patch-ids.c: use ALLOC_GROW() in add_commit()\n      replace_object.c: use ALLOC_GROW() in register_replace_object()\n      reflog-walk.c: use ALLOC_GROW() instead of inline code\n      dir.c: use ALLOC_GROW() in create_simplify()\n      attr.c: use ALLOC_GROW() in handle_attr_line()\n\nbut I tend to agree with you that we can just stop at \"use ALLOC_GROW\"\nafter the filename.\n"},{"id":"235906","messageId":"xmqqr46jp0db.fsf@gitster.dls.corp.google.com","threadId":"35982","inReplyTo":"CAPig+cQ-6h3JJr5uUu0J1_m+ENfFq2X4CusetPssQuJNB61zCA@mail.gmail.com","subject":"Re: [PATCH v3 00/11] Use ALLOC_GROW() instead of inline code","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-03T19:07:12Z","receivedAt":"2014-03-03T19:07:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Mon, Mar 3, 2014 at 2:18 AM, Dmitry S. Dolzhenko\n> <dmitrys.dolzhenko@yandex.ru> wrote:\n>> Dmitry S. Dolzhenko (11):\n>>   builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path()\n>>   bundle.c: use ALLOC_GROW() in add_to_ref_list()\n>>   cache-tree.c: use ALLOC_GROW() in find_subtree()\n>>   commit.c: use ALLOC_GROW() in register_commit_graft()\n>>   diff.c: use ALLOC_GROW()\n>>   diffcore-rename.c: use ALLOC_GROW()\n>>   patch-ids.c: use ALLOC_GROW() in add_commit()\n>>   replace_object.c: use ALLOC_GROW() in register_replace_object()\n>>   reflog-walk.c: use ALLOC_GROW()\n>>   dir.c: use ALLOC_GROW() in create_simplify()\n>>   attr.c: use ALLOC_GROW() in handle_attr_line()\n>>\n>>  attr.c                 |  7 +------\n>>  builtin/pack-objects.c |  9 +++------\n>>  bundle.c               |  6 +-----\n>>  cache-tree.c           |  6 +-----\n>>  commit.c               |  8 ++------\n>>  diff.c                 | 12 ++----------\n>>  diffcore-rename.c      | 12 ++----------\n>>  dir.c                  |  5 +----\n>>  patch-ids.c            |  5 +----\n>>  reflog-walk.c          | 12 ++----------\n>>  replace_object.c       |  8 ++------\n>>  11 files changed, 18 insertions(+), 72 deletions(-)\n>>\n>> --\n>> 1.8.5.3\n>>\n>> This version differs from previous only minor changes:\n>>   - update commit messages\n>>   - keep code lines within 80 columns\n>\n> Place this commentary at the top of the cover letter since that's\n> where people look for it.\n>\n> You want to ease the reviewer's job as much as possible, so it helps\n> to link to the previous submission, like this [1].\n>\n> Likewise, you can help the reviewer by being more specific about how\n> you updated the commit messages (and perhaps by linking to the\n> relevant discussion points, like this [2][3]).\n>\n> [1]: http://thread.gmane.org/gmane.comp.version-control.git/242857\n> [2]: http://article.gmane.org/gmane.comp.version-control.git/243004\n> [3]: http://article.gmane.org/gmane.comp.version-control.git/243049\n\nIt would be helpful for people to also pay attention to what is\npushed out on 'pu' ;-)\n"}]}