summaryrefslogtreecommitdiff
path: root/add-interactive.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-03-06 11:26:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-03-08 17:45:04 (GMT)
commit241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1 (patch)
tree2912c1f5896fb1356a4ba09fa48129e1a5dd310f /add-interactive.c
parent59ec22464f6c2b170b05f287e00740ea2288fe5c (diff)
downloadgit-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.zip
git-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.tar.gz
git-241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1.tar.bz2
fix xcalloc() argument order
Pass the number of elements first and ther size second, as expected by xcalloc(). Provide a semantic patch, which was actually used to generate the rest of this patch. The semantic patch would generate flip-flop diffs if both arguments are sizeofs. We don't have such a case, and it's hard to imagine the usefulness of such an allocation. If it ever occurs then we could deal with it by duplicating the rule in the semantic patch to make it cancel itself out, or we could change the code to use CALLOC_ARRAY. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
-rw-r--r--add-interactive.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/add-interactive.c b/add-interactive.c
index 9b8cdb4..09faee0 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -413,7 +413,7 @@ struct file_item {
static void add_file_item(struct string_list *files, const char *name)
{
- struct file_item *item = xcalloc(sizeof(*item), 1);
+ struct file_item *item = xcalloc(1, sizeof(*item));
string_list_append(files, name)->util = item;
}
@@ -476,7 +476,7 @@ static void collect_changes_cb(struct diff_queue_struct *q,
add_file_item(s->files, name);
- entry = xcalloc(sizeof(*entry), 1);
+ entry = xcalloc(1, sizeof(*entry));
hashmap_entry_init(&entry->ent, hash);
entry->name = s->files->items[s->files->nr - 1].string;
entry->item = s->files->items[s->files->nr - 1].util;
@@ -1120,7 +1120,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
int res = 0;
for (i = 0; i < ARRAY_SIZE(command_list); i++) {
- struct command_item *util = xcalloc(sizeof(*util), 1);
+ struct command_item *util = xcalloc(1, sizeof(*util));
util->command = command_list[i].command;
string_list_append(&commands.items, command_list[i].string)
->util = util;