ps_matched: xcalloc() takes nmemb and then element size

Even though multiplication is commutative, the order of arguments should be xcalloc(nmemb, size). ps_matched is an array of 1-byte element whose size is the same as the number of pathspec elements. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 20, 2015 at 09:57 UTC 8b54c23437834b36bbb5f6de2f577400385da770
2 files changed +2 -2
builtin/checkout.c
+1 -1
@@ -280,7 +280,7 @@ static int checkout_paths(const struct checkout_opts *opts,
280 if (opts->source_tree)
281 read_tree_some(opts->source_tree, &opts->pathspec);
282
283 - ps_matched = xcalloc(1, opts->pathspec.nr);
283 + ps_matched = xcalloc(opts->pathspec.nr, 1);
284
285 /*
286 * Make sure all pathspecs participated in locating the paths
builtin/ls-files.c
+1 -1
@@ -516,7 +516,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
516
517 /* Treat unmatching pathspec elements as errors */
518 if (pathspec.nr && error_unmatch)
519 - ps_matched = xcalloc(1, pathspec.nr);
519 + ps_matched = xcalloc(pathspec.nr, 1);
520
521 if ((dir.flags & DIR_SHOW_IGNORED) && !exc_given)
522 die("ls-files --ignored needs some exclude pattern");