1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-22 02:46:10 +02:00

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
This commit is contained in:
Junio C Hamano 2014-07-22 10:25:17 -07:00
commit cfececfe1f
12 changed files with 21 additions and 21 deletions

View File

@ -92,7 +92,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
if (argv[i]) {
int j;
pattern = xcalloc(sizeof(const char *), argc - i + 1);
pattern = xcalloc(argc - i + 1, sizeof(const char *));
for (j = i; j < argc; j++) {
int len = strlen(argv[j]);
char *p = xmalloc(len + 3);

View File

@ -282,7 +282,7 @@ static int config_read_branches(const char *key, const char *value, void *cb)
item = string_list_insert(&branch_list, name);
if (!item->util)
item->util = xcalloc(sizeof(struct branch_info), 1);
item->util = xcalloc(1, sizeof(struct branch_info));
info = item->util;
if (type == REMOTE) {
if (info->remote_name)
@ -398,7 +398,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
item = string_list_append(&states->push,
abbrev_branch(ref->peer_ref->name));
item->util = xcalloc(sizeof(struct push_info), 1);
item->util = xcalloc(1, sizeof(struct push_info));
info = item->util;
info->forced = ref->force;
info->dest = xstrdup(abbrev_branch(ref->name));
@ -433,7 +433,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
states->push.strdup_strings = 1;
if (!remote->push_refspec_nr) {
item = string_list_append(&states->push, _("(matching)"));
info = item->util = xcalloc(sizeof(struct push_info), 1);
info = item->util = xcalloc(1, sizeof(struct push_info));
info->status = PUSH_STATUS_NOTQUERIED;
info->dest = xstrdup(item->string);
}
@ -446,7 +446,7 @@ static int get_push_ref_states_noquery(struct ref_states *states)
else
item = string_list_append(&states->push, _("(delete)"));
info = item->util = xcalloc(sizeof(struct push_info), 1);
info = item->util = xcalloc(1, sizeof(struct push_info));
info->forced = spec->force;
info->status = PUSH_STATUS_NOTQUERIED;
info->dest = xstrdup(spec->dst ? spec->dst : item->string);

View File

@ -1089,7 +1089,7 @@ struct commit_list *reduce_heads(struct commit_list *heads)
p->item->object.flags |= STALE;
num_head++;
}
array = xcalloc(sizeof(*array), num_head);
array = xcalloc(num_head, sizeof(*array));
for (p = heads, i = 0; p; p = p->next) {
if (p->item->object.flags & STALE) {
array[i++] = p->item;

View File

@ -1538,7 +1538,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
* The lock serves a purpose in addition to locking: the new
* contents of .git/config will be written into it.
*/
lock = xcalloc(sizeof(struct lock_file), 1);
lock = xcalloc(1, sizeof(struct lock_file));
fd = hold_lock_file_for_update(lock, config_filename, 0);
if (fd < 0) {
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,
if (!config_filename)
config_filename = filename_buf = git_pathdup("config");
lock = xcalloc(sizeof(struct lock_file), 1);
lock = xcalloc(1, sizeof(struct lock_file));
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0) {
ret = error("could not lock config file %s", config_filename);

2
diff.c
View File

@ -1361,7 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
const char *name_b)
{
struct diffstat_file *x;
x = xcalloc(sizeof (*x), 1);
x = xcalloc(1, sizeof(*x));
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
diffstat->files[diffstat->nr++] = x;
if (name_b) {

View File

@ -1732,7 +1732,7 @@ int main(int argc, char **argv)
git_extract_argv0_path(argv[0]);
repo = xcalloc(sizeof(*repo), 1);
repo = xcalloc(1, sizeof(*repo));
argv++;
for (i = 1; i < argc; i++, argv++) {

View File

@ -951,7 +951,7 @@ static struct imap_store *imap_open_store(struct imap_server_conf *srvc)
char *arg, *rsp;
int s = -1, preauth;
ctx = xcalloc(sizeof(*ctx), 1);
ctx = xcalloc(1, sizeof(*ctx));
ctx->imap = imap = xcalloc(sizeof(*imap), 1);
imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;

View File

@ -303,7 +303,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
free(entry);
return 0;
}
new_node = (struct int_node *) xcalloc(sizeof(struct int_node), 1);
new_node = (struct int_node *) xcalloc(1, sizeof(struct int_node));
ret = note_tree_insert(t, new_node, n + 1, l, GET_PTR_TYPE(*p),
combine_notes);
if (ret)
@ -443,7 +443,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
if (len <= 20) {
type = PTR_TYPE_NOTE;
l = (struct leaf_node *)
xcalloc(sizeof(struct leaf_node), 1);
xcalloc(1, sizeof(struct leaf_node));
hashcpy(l->key_sha1, object_sha1);
hashcpy(l->val_sha1, entry.sha1);
if (len < 20) {
@ -1003,7 +1003,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
if (!combine_notes)
combine_notes = combine_notes_concatenate;
t->root = (struct int_node *) xcalloc(sizeof(struct int_node), 1);
t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));
t->first_non_note = NULL;
t->prev_non_note = NULL;
t->ref = notes_ref ? xstrdup(notes_ref) : NULL;

View File

@ -45,7 +45,7 @@ static void init_pack_revindex(void)
if (!num)
return;
pack_revindex_hashsz = num * 11;
pack_revindex = xcalloc(sizeof(*pack_revindex), pack_revindex_hashsz);
pack_revindex = xcalloc(pack_revindex_hashsz, sizeof(*pack_revindex));
for (p = packed_git; p; p = p->next) {
num = pack_revindex_ix(p);
num = - 1 - num;

View File

@ -41,7 +41,7 @@ static int read_one_reflog(unsigned char *osha1, unsigned char *nsha1,
static struct complete_reflogs *read_complete_reflog(const char *ref)
{
struct complete_reflogs *reflogs =
xcalloc(sizeof(struct complete_reflogs), 1);
xcalloc(1, sizeof(struct complete_reflogs));
reflogs->ref = xstrdup(ref);
for_each_reflog_ent(ref, read_one_reflog, reflogs);
if (reflogs->nr == 0) {
@ -135,7 +135,7 @@ struct reflog_walk_info {
void init_reflog_walk(struct reflog_walk_info** info)
{
*info = xcalloc(sizeof(struct reflog_walk_info), 1);
*info = xcalloc(1, sizeof(struct reflog_walk_info));
}
int add_reflog_for_walk(struct reflog_walk_info *info,
@ -199,7 +199,7 @@ int add_reflog_for_walk(struct reflog_walk_info *info,
= reflogs;
}
commit_reflog = xcalloc(sizeof(struct commit_reflog), 1);
commit_reflog = xcalloc(1, sizeof(struct commit_reflog));
if (recno < 0) {
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
if (commit_reflog->recno < 0) {
@ -242,7 +242,7 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)
return;
}
commit->parents = xcalloc(sizeof(struct commit_list), 1);
commit->parents = xcalloc(1, sizeof(struct commit_list));
commit->parents->item = commit_info->commit;
}

View File

@ -523,7 +523,7 @@ static void free_refspecs(struct refspec *refspec, int nr_refspec)
static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
{
int i;
struct refspec *rs = xcalloc(sizeof(*rs), nr_refspec);
struct refspec *rs = xcalloc(nr_refspec, sizeof(*rs));
for (i = 0; i < nr_refspec; i++) {
size_t llen;

View File

@ -1026,7 +1026,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
int transport_helper_init(struct transport *transport, const char *name)
{
struct helper_data *data = xcalloc(sizeof(*data), 1);
struct helper_data *data = xcalloc(1, sizeof(*data));
data->name = name;
if (getenv("GIT_TRANSPORT_HELPER_DEBUG"))