Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2021-03-06 14:26:19 +0300
committerJunio C Hamano <gitster@pobox.com>2021-03-08 20:45:04 +0300
commit241b5d3ebeea21b70a74fdc8c74e73f7ed829cb1 (patch)
tree2912c1f5896fb1356a4ba09fa48129e1a5dd310f /add-interactive.c
parent59ec22464f6c2b170b05f287e00740ea2288fe5c (diff)
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 9b8cdb4a31..09faee0e8f 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;