diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/apply.c | 2 | ||||
-rw-r--r-- | builtin/for-each-ref.c | 9 | ||||
-rw-r--r-- | builtin/index-pack.c | 4 | ||||
-rw-r--r-- | builtin/log.c | 2 | ||||
-rw-r--r-- | builtin/merge.c | 2 | ||||
-rw-r--r-- | builtin/mv.c | 8 | ||||
-rw-r--r-- | builtin/pack-objects.c | 3 | ||||
-rw-r--r-- | builtin/show-branch.c | 2 |
8 files changed, 13 insertions, 19 deletions
diff --git a/builtin/apply.c b/builtin/apply.c index f204cca5d2..8714a88720 100644 --- a/builtin/apply.c +++ b/builtin/apply.c @@ -2626,7 +2626,7 @@ static void update_image(struct image *img, * NOTE: this knows that we never call remove_first_line() * on anything other than pre/post image. */ - img->line = xrealloc(img->line, nr * sizeof(*img->line)); + REALLOC_ARRAY(img->line, nr); img->line_allocated = img->line; } if (preimage_limit != postimage->nr) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 47bd624696..7f55e68167 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -138,10 +138,8 @@ static int parse_atom(const char *atom, const char *ep) /* Add it in, including the deref prefix */ at = used_atom_cnt; used_atom_cnt++; - used_atom = xrealloc(used_atom, - (sizeof *used_atom) * used_atom_cnt); - used_atom_type = xrealloc(used_atom_type, - (sizeof(*used_atom_type) * used_atom_cnt)); + REALLOC_ARRAY(used_atom, used_atom_cnt); + REALLOC_ARRAY(used_atom_type, used_atom_cnt); used_atom[at] = xmemdupz(atom, ep - atom); used_atom_type[at] = valid_atom[i].cmp_type; if (*atom == '*') @@ -870,8 +868,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f ref->flag = flag; cnt = cb->grab_cnt; - cb->grab_array = xrealloc(cb->grab_array, - sizeof(*cb->grab_array) * (cnt + 1)); + REALLOC_ARRAY(cb->grab_array, cnt + 1); cb->grab_array[cnt++] = ref; cb->grab_cnt = cnt; return 0; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 5568a5bc3b..783623dbe2 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1140,9 +1140,7 @@ static void conclude_pack(int fix_thin_pack, const char *curr_pack, unsigned cha int nr_objects_initial = nr_objects; if (nr_unresolved <= 0) die(_("confusion beyond insanity")); - objects = xrealloc(objects, - (nr_objects + nr_unresolved + 1) - * sizeof(*objects)); + REALLOC_ARRAY(objects, nr_objects + nr_unresolved + 1); memset(objects + nr_objects + 1, 0, nr_unresolved * sizeof(*objects)); f = sha1fd(output_fd, curr_pack); diff --git a/builtin/log.c b/builtin/log.c index e4d812208d..7643396aec 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1440,7 +1440,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) continue; nr++; - list = xrealloc(list, nr * sizeof(list[0])); + REALLOC_ARRAY(list, nr); list[nr - 1] = commit; } if (nr == 0) diff --git a/builtin/merge.c b/builtin/merge.c index 9da9e30d9b..cb9af1e3dd 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -556,7 +556,7 @@ static void parse_branch_merge_options(char *bmo) if (argc < 0) die(_("Bad branch.%s.mergeoptions string: %s"), branch, split_cmdline_strerror(argc)); - argv = xrealloc(argv, sizeof(*argv) * (argc + 2)); + REALLOC_ARRAY(argv, argc + 2); memmove(argv + 1, argv, sizeof(*argv) * (argc + 1)); argc++; argv[0] = "branch.*.mergeoptions"; diff --git a/builtin/mv.c b/builtin/mv.c index bf784cb943..8883baa903 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -184,10 +184,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix) modes[i] = WORKING_DIRECTORY; n = argc + last - first; - source = xrealloc(source, n * sizeof(char *)); - destination = xrealloc(destination, n * sizeof(char *)); - modes = xrealloc(modes, n * sizeof(enum update_mode)); - submodule_gitfile = xrealloc(submodule_gitfile, n * sizeof(char *)); + REALLOC_ARRAY(source, n); + REALLOC_ARRAY(destination, n); + REALLOC_ARRAY(modes, n); + REALLOC_ARRAY(submodule_gitfile, n); dst = add_slash(dst); dst_len = strlen(dst); diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index b59f5d895e..d39193453a 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -89,8 +89,7 @@ static void index_commit_for_bitmap(struct commit *commit) { if (indexed_commits_nr >= indexed_commits_alloc) { indexed_commits_alloc = (indexed_commits_alloc + 32) * 2; - indexed_commits = xrealloc(indexed_commits, - indexed_commits_alloc * sizeof(struct commit *)); + REALLOC_ARRAY(indexed_commits, indexed_commits_alloc); } indexed_commits[indexed_commits_nr++] = commit; diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 298c95e3f8..a1275237ee 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -563,7 +563,7 @@ static int git_show_branch_config(const char *var, const char *value, void *cb) default_arg[default_num++] = "show-branch"; } else if (default_alloc <= default_num + 1) { default_alloc = default_alloc * 3 / 2 + 20; - default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc); + REALLOC_ARRAY(default_arg, default_alloc); } default_arg[default_num++] = xstrdup(value); default_arg[default_num] = NULL; |