Skip to content

Commit cfececf

Browse files
committed
Merge branch 'bg/xcalloc-nmemb-then-size' into maint
* bg/xcalloc-nmemb-then-size: transport-helper.c: rearrange xcalloc arguments remote.c: rearrange xcalloc arguments reflog-walk.c: rearrange xcalloc arguments pack-revindex.c: rearrange xcalloc arguments notes.c: rearrange xcalloc arguments imap-send.c: rearrange xcalloc arguments http-push.c: rearrange xcalloc arguments diff.c: rearrange xcalloc arguments config.c: rearrange xcalloc arguments commit.c: rearrange xcalloc arguments builtin/remote.c: rearrange xcalloc arguments builtin/ls-remote.c: rearrange xcalloc arguments
2 parents 1fbc6e6 + 92e25b6 commit cfececf

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

builtin/ls-remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
9292

9393
if (argv[i]) {
9494
int j;
95-
pattern = xcalloc(sizeof(const char *), argc - i + 1);
95+
pattern = xcalloc(argc - i + 1, sizeof(const char *));
9696
for (j = i; j < argc; j++) {
9797
int len = strlen(argv[j]);
9898
char *p = xmalloc(len + 3);

builtin/remote.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
282282
item = string_list_insert(&branch_list, name);
283283

284284
if (!item->util)
285-
item->util = xcalloc(sizeof(struct branch_info), 1);
285+
item->util = xcalloc(1, sizeof(struct branch_info));
286286
info = item->util;
287287
if (type == REMOTE) {
288288
if (info->remote_name)
@@ -398,7 +398,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
398398

399399
item = string_list_append(&states->push,
400400
abbrev_branch(ref->peer_ref->name));
401-
item->util = xcalloc(sizeof(struct push_info), 1);
401+
item->util = xcalloc(1, sizeof(struct push_info));
402402
info = item->util;
403403
info->forced = ref->force;
404404
info->dest = xstrdup(abbrev_branch(ref->name));
@@ -433,7 +433,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
433433
states->push.strdup_strings = 1;
434434
if (!remote->push_refspec_nr) {
435435
item = string_list_append(&states->push, _("(matching)"));
436-
info = item->util = xcalloc(sizeof(struct push_info), 1);
436+
info = item->util = xcalloc(1, sizeof(struct push_info));
437437
info->status = PUSH_STATUS_NOTQUERIED;
438438
info->dest = xstrdup(item->string);
439439
}
@@ -446,7 +446,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
446446
else
447447
item = string_list_append(&states->push, _("(delete)"));
448448

449-
info = item->util = xcalloc(sizeof(struct push_info), 1);
449+
info = item->util = xcalloc(1, sizeof(struct push_info));
450450
info->forced = spec->force;
451451
info->status = PUSH_STATUS_NOTQUERIED;
452452
info->dest = xstrdup(spec->dst ? spec->dst : item->string);

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
10891089
p->item->object.flags |= STALE;
10901090
num_head++;
10911091
}
1092-
array = xcalloc(sizeof(*array), num_head);
1092+
array = xcalloc(num_head, sizeof(*array));
10931093
for (p = heads, i = 0; p; p = p->next) {
10941094
if (p->item->object.flags & STALE) {
10951095
array[i++] = p->item;

config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
15381538
* The lock serves a purpose in addition to locking: the new
15391539
* contents of .git/config will be written into it.
15401540
*/
1541-
lock = xcalloc(sizeof(struct lock_file), 1);
1541+
lock = xcalloc(1, sizeof(struct lock_file));
15421542
fd = hold_lock_file_for_update(lock, config_filename, 0);
15431543
if (fd < 0) {
15441544
error("could not lock config file %s: %s", config_filename, strerror(errno));
@@ -1793,7 +1793,7 @@ int git_config_rename_section_in_file(const char *config_filename,
17931793
if (!config_filename)
17941794
config_filename = filename_buf = git_pathdup("config");
17951795

1796-
lock = xcalloc(sizeof(struct lock_file), 1);
1796+
lock = xcalloc(1, sizeof(struct lock_file));
17971797
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
17981798
if (out_fd < 0) {
17991799
ret = error("could not lock config file %s", config_filename);

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
13611361
const char *name_b)
13621362
{
13631363
struct diffstat_file *x;
1364-
x = xcalloc(sizeof (*x), 1);
1364+
x = xcalloc(1, sizeof(*x));
13651365
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
13661366
diffstat->files[diffstat->nr++] = x;
13671367
if (name_b) {

http-push.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ int main(int argc, char **argv)
17321732

17331733
git_extract_argv0_path(argv[0]);
17341734

1735-
repo = xcalloc(sizeof(*repo), 1);
1735+
repo = xcalloc(1, sizeof(*repo));
17361736

17371737
argv++;
17381738
for (i = 1; i < argc; i++, argv++) {

imap-send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
951951
char *arg, *rsp;
952952
int s = -1, preauth;
953953

954-
ctx = xcalloc(sizeof(*ctx), 1);
954+
ctx = xcalloc(1, sizeof(*ctx));
955955

956956
ctx->imap = imap = xcalloc(sizeof(*imap), 1);
957957
imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;

notes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
303303
free(entry);
304304
return 0;
305305
}
306-
new_node = (struct int_node *) xcalloc(sizeof(struct int_node), 1);
306+
new_node = (struct int_node *) xcalloc(1, sizeof(struct int_node));
307307
ret = note_tree_insert(t, new_node, n + 1, l, GET_PTR_TYPE(*p),
308308
combine_notes);
309309
if (ret)
@@ -443,7 +443,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
443443
if (len <= 20) {
444444
type = PTR_TYPE_NOTE;
445445
l = (struct leaf_node *)
446-
xcalloc(sizeof(struct leaf_node), 1);
446+
xcalloc(1, sizeof(struct leaf_node));
447447
hashcpy(l->key_sha1, object_sha1);
448448
hashcpy(l->val_sha1, entry.sha1);
449449
if (len < 20) {
@@ -1003,7 +1003,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
10031003
if (!combine_notes)
10041004
combine_notes = combine_notes_concatenate;
10051005

1006-
t->root = (struct int_node *) xcalloc(sizeof(struct int_node), 1);
1006+
t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));
10071007
t->first_non_note = NULL;
10081008
t->prev_non_note = NULL;
10091009
t->ref = notes_ref ? xstrdup(notes_ref) : NULL;

pack-revindex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void init_pack_revindex(void)
4545
if (!num)
4646
return;
4747
pack_revindex_hashsz = num * 11;
48-
pack_revindex = xcalloc(sizeof(*pack_revindex), pack_revindex_hashsz);
48+
pack_revindex = xcalloc(pack_revindex_hashsz, sizeof(*pack_revindex));
4949
for (p = packed_git; p; p = p->next) {
5050
num = pack_revindex_ix(p);
5151
num = - 1 - num;

reflog-walk.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
4141
static struct complete_reflogs *read_complete_reflog(const char *ref)
4242
{
4343
struct complete_reflogs *reflogs =
44-
xcalloc(sizeof(struct complete_reflogs), 1);
44+
xcalloc(1, sizeof(struct complete_reflogs));
4545
reflogs->ref = xstrdup(ref);
4646
for_each_reflog_ent(ref, read_one_reflog, reflogs);
4747
if (reflogs->nr == 0) {
@@ -135,7 +135,7 @@ struct reflog_walk_info {
135135

136136
void init_reflog_walk(struct reflog_walk_info** info)
137137
{
138-
*info = xcalloc(sizeof(struct reflog_walk_info), 1);
138+
*info = xcalloc(1, sizeof(struct reflog_walk_info));
139139
}
140140

141141
int add_reflog_for_walk(struct reflog_walk_info *info,
@@ -199,7 +199,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
199199
= reflogs;
200200
}
201201

202-
commit_reflog = xcalloc(sizeof(struct commit_reflog), 1);
202+
commit_reflog = xcalloc(1, sizeof(struct commit_reflog));
203203
if (recno < 0) {
204204
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
205205
if (commit_reflog->recno < 0) {
@@ -242,7 +242,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
242242
return;
243243
}
244244

245-
commit->parents = xcalloc(sizeof(struct commit_list), 1);
245+
commit->parents = xcalloc(1, sizeof(struct commit_list));
246246
commit->parents->item = commit_info->commit;
247247
}
248248

0 commit comments

Comments
 (0)