Add and apply a semantic patch for converting code that open-codes
CALLOC_ARRAY to use it instead. It shortens the code and infers the
element size automatically.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
88 files changed:
add_file_item(s->files, name);
add_file_item(s->files, name);
- entry = xcalloc(sizeof(*entry), 1);
+ CALLOC_ARRAY(entry, 1);
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;
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;
struct fragment *fragment;
int len;
struct fragment *fragment;
int len;
- fragment = xcalloc(1, sizeof(*fragment));
+ CALLOC_ARRAY(fragment, 1);
fragment->linenr = state->linenr;
len = parse_fragment(state, line, size, patch, fragment);
if (len <= 0) {
fragment->linenr = state->linenr;
len = parse_fragment(state, line, size, patch, fragment);
if (len <= 0) {
- frag = xcalloc(1, sizeof(*frag));
frag->patch = inflate_it(data, hunk_size, origlen);
frag->free_patch = 1;
if (!frag->patch)
frag->patch = inflate_it(data, hunk_size, origlen);
frag->free_patch = 1;
if (!frag->patch)
struct patch *patch;
int nr;
struct patch *patch;
int nr;
- patch = xcalloc(1, sizeof(*patch));
+ CALLOC_ARRAY(patch, 1);
patch->inaccurate_eof = !!(options & APPLY_OPT_INACCURATE_EOF);
patch->recount = !!(options & APPLY_OPT_RECOUNT);
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
patch->inaccurate_eof = !!(options & APPLY_OPT_INACCURATE_EOF);
patch->recount = !!(options & APPLY_OPT_RECOUNT);
nr = parse_chunk(state, buf.buf + offset, buf.len - offset, patch);
ar = find_tar_filter(name, namelen);
if (!ar) {
ar = find_tar_filter(name, namelen);
if (!ar) {
- ar = xcalloc(1, sizeof(*ar));
ar->name = xmemdupz(name, namelen);
ar->write_archive = write_tar_filter_archive;
ar->flags = ARCHIVER_WANT_COMPRESSION_LEVELS |
ar->name = xmemdupz(name, namelen);
ar->write_archive = write_tar_filter_archive;
ar->flags = ARCHIVER_WANT_COMPRESSION_LEVELS |
check = attr_check_alloc();
check->nr = cnt;
check->alloc = cnt;
check = attr_check_alloc();
check->nr = cnt;
check->alloc = cnt;
- check->items = xcalloc(cnt, sizeof(struct attr_check_item));
+ CALLOC_ARRAY(check->items, cnt);
check->items[0].attr = git_attr(one);
va_start(params, one);
check->items[0].attr = git_attr(one);
va_start(params, one);
const char *line;
int lineno = 0;
const char *line;
int lineno = 0;
- res = xcalloc(1, sizeof(*res));
while ((line = *(list++)) != NULL)
handle_attr_line(res, line, "[builtin]", ++lineno, 1);
return res;
while ((line = *(list++)) != NULL)
handle_attr_line(res, line, "[builtin]", ++lineno, 1);
return res;
- res = xcalloc(1, sizeof(*res));
while (fgets(buf, sizeof(buf), fp)) {
char *bufp = buf;
if (!lineno)
while (fgets(buf, sizeof(buf), fp)) {
char *bufp = buf;
if (!lineno)
- res = xcalloc(1, sizeof(*res));
for (sp = buf; *sp; ) {
char *ep;
int more;
for (sp = buf; *sp; ) {
char *ep;
int more;
- res = xcalloc(1, sizeof(*res));
- e = xcalloc(1, sizeof(struct attr_stack));
push_stack(stack, e, NULL, 0);
}
push_stack(stack, e, NULL, 0);
}
show_list("bisection 2 sorted", 0, nr, list);
*all = nr;
show_list("bisection 2 sorted", 0, nr, list);
*all = nr;
- weights = xcalloc(on_list, sizeof(*weights));
+ CALLOC_ARRAY(weights, on_list);
/* Do the real work of finding bisection commit. */
best = do_find_bisection(list, nr, weights, bisect_flags);
/* Do the real work of finding bisection commit. */
best = do_find_bisection(list, nr, weights, bisect_flags);
max_search_distance_b = ((2 * max_search_distance_a + 1) * length_b
- 1) / length_a;
max_search_distance_b = ((2 * max_search_distance_a + 1) * length_b
- 1) / length_a;
- result = xcalloc(sizeof(int), length_b);
- second_best_result = xcalloc(sizeof(int), length_b);
- certainties = xcalloc(sizeof(int), length_b);
+ CALLOC_ARRAY(result, length_b);
+ CALLOC_ARRAY(second_best_result, length_b);
+ CALLOC_ARRAY(certainties, length_b);
/* See get_similarity() for details of similarities. */
similarity_count = length_b * (max_search_distance_a * 2 + 1);
/* See get_similarity() for details of similarities. */
similarity_count = length_b * (max_search_distance_a * 2 + 1);
- similarities = xcalloc(sizeof(int), similarity_count);
+ CALLOC_ARRAY(similarities, similarity_count);
for (i = 0; i < length_b; ++i) {
result[i] = -1;
for (i = 0; i < length_b; ++i) {
result[i] = -1;
return;
o->num_lines = find_line_starts(&line_starts, o->file.ptr,
o->file.size);
return;
o->num_lines = find_line_starts(&line_starts, o->file.ptr,
o->file.size);
- o->fingerprints = xcalloc(sizeof(struct fingerprint), o->num_lines);
+ CALLOC_ARRAY(o->fingerprints, o->num_lines);
get_line_fingerprints(o->fingerprints, o->file.ptr, line_starts,
0, o->num_lines);
free(line_starts);
get_line_fingerprints(o->fingerprints, o->file.ptr, line_starts,
0, o->num_lines);
free(line_starts);
diffp = NULL;
if (ignore_diffs && same - tlno > 0) {
diffp = NULL;
if (ignore_diffs && same - tlno > 0) {
- line_blames = xcalloc(sizeof(struct blame_line_tracker),
- same - tlno);
+ CALLOC_ARRAY(line_blames, same - tlno);
guess_line_blames(parent, target, tlno, offset, same,
parent_len, line_blames);
}
guess_line_blames(parent, target, tlno, offset, same,
parent_len, line_blames);
}
for (e = unblamed, num_ents = 0; e; e = e->next)
num_ents++;
if (num_ents) {
for (e = unblamed, num_ents = 0; e; e = e->next)
num_ents++;
if (num_ents) {
- blame_list = xcalloc(num_ents, sizeof(struct blame_list));
+ CALLOC_ARRAY(blame_list, num_ents);
for (e = unblamed, i = 0; e; e = e->next)
blame_list[i++].ent = e;
}
for (e = unblamed, i = 0; e; e = e->next)
blame_list[i++].ent = e;
}
else if (num_sg < ARRAY_SIZE(sg_buf))
memset(sg_buf, 0, sizeof(sg_buf));
else
else if (num_sg < ARRAY_SIZE(sg_buf))
memset(sg_buf, 0, sizeof(sg_buf));
else
- sg_origin = xcalloc(num_sg, sizeof(*sg_origin));
+ CALLOC_ARRAY(sg_origin, num_sg);
/*
* The first pass looks for unrenamed path to optimize for
/*
* The first pass looks for unrenamed path to optimize for
*computed |= BLOOM_TRUNC_EMPTY;
filter->len = 1;
}
*computed |= BLOOM_TRUNC_EMPTY;
filter->len = 1;
}
- filter->data = xcalloc(filter->len, sizeof(unsigned char));
+ CALLOC_ARRAY(filter->data, filter->len);
hashmap_for_each_entry(&pathmap, &iter, e, entry) {
struct bloom_key key;
hashmap_for_each_entry(&pathmap, &iter, e, entry) {
struct bloom_key key;
- result = xcalloc(st_add(nr, 1), sizeof(int));
+ CALLOC_ARRAY(result, st_add(nr, 1));
for (i = 0; i < stuff->nr && j < nr; i++) {
if (chosen[i])
result[j++] = i;
for (i = 0; i < stuff->nr && j < nr; i++) {
if (chosen[i])
result[j++] = i;
die(_("Expected format name:filename for submodule rewrite option"));
*f = '\0';
f++;
die(_("Expected format name:filename for submodule rewrite option"));
*f = '\0';
f++;
- ms = xcalloc(1, sizeof(*ms));
fp = fopen(f, "r");
if (!fp)
fp = fopen(f, "r");
if (!fp)
alloc_objects(object_entry_alloc);
strbuf_init(&command_buf, 0);
alloc_objects(object_entry_alloc);
strbuf_init(&command_buf, 0);
- atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));
- branch_table = xcalloc(branch_table_sz, sizeof(struct branch*));
- avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
+ CALLOC_ARRAY(atom_table, atom_table_sz);
+ CALLOC_ARRAY(branch_table, branch_table_sz);
+ CALLOC_ARRAY(avail_tree_table, avail_tree_table_sz);
marks = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct mark_set));
hashmap_init(&object_table, object_entry_hashcmp, NULL, 0);
marks = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct mark_set));
hashmap_init(&object_table, object_entry_hashcmp, NULL, 0);
strbuf_init(&todo[i].out, 0);
}
strbuf_init(&todo[i].out, 0);
}
- threads = xcalloc(num_threads, sizeof(*threads));
+ CALLOC_ARRAY(threads, num_threads);
for (i = 0; i < num_threads; i++) {
int err;
struct grep_opt *o = grep_opt_dup(opt);
for (i = 0; i < num_threads; i++) {
int err;
struct grep_opt *o = grep_opt_dup(opt);
if (show_stat)
pthread_mutex_init(&deepest_delta_mutex, NULL);
pthread_key_create(&key, NULL);
if (show_stat)
pthread_mutex_init(&deepest_delta_mutex, NULL);
pthread_key_create(&key, NULL);
- thread_data = xcalloc(nr_threads, sizeof(*thread_data));
+ CALLOC_ARRAY(thread_data, nr_threads);
for (i = 0; i < nr_threads; i++) {
thread_data[i].pack_fd = open(curr_pack, O_RDONLY);
if (thread_data[i].pack_fd == -1)
for (i = 0; i < nr_threads; i++) {
thread_data[i].pack_fd = open(curr_pack, O_RDONLY);
if (thread_data[i].pack_fd == -1)
unsigned long *chain_histogram = NULL;
if (deepest_delta)
unsigned long *chain_histogram = NULL;
if (deepest_delta)
- chain_histogram = xcalloc(deepest_delta, sizeof(unsigned long));
+ CALLOC_ARRAY(chain_histogram, deepest_delta);
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
for (i = 0; i < nr_objects; i++) {
struct object_entry *obj = &objects[i];
curr_pack = open_pack_file(pack_name);
parse_pack_header();
curr_pack = open_pack_file(pack_name);
parse_pack_header();
- objects = xcalloc(st_add(nr_objects, 1), sizeof(struct object_entry));
+ CALLOC_ARRAY(objects, st_add(nr_objects, 1));
- obj_stat = xcalloc(st_add(nr_objects, 1), sizeof(struct object_stat));
- ofs_deltas = xcalloc(nr_objects, sizeof(struct ofs_delta_entry));
+ CALLOC_ARRAY(obj_stat, st_add(nr_objects, 1));
+ CALLOC_ARRAY(ofs_deltas, nr_objects);
parse_pack_objects(pack_hash);
if (report_end_of_input)
write_in_full(2, "\0", 1);
parse_pack_objects(pack_hash);
if (report_end_of_input)
write_in_full(2, "\0", 1);
- pattern = xcalloc(argc, sizeof(const char *));
+ CALLOC_ARRAY(pattern, argc);
for (i = 1; i < argc; i++) {
pattern[i - 1] = xstrfmt("*/%s", argv[i]);
}
for (i = 1; i < argc; i++) {
pattern[i - 1] = xstrfmt("*/%s", argv[i]);
}
- ret = xcalloc(1, sizeof(struct strategy));
ret->name = xstrdup(name);
ret->attr = NO_TRIVIAL;
return ret;
ret->name = xstrdup(name);
ret->attr = NO_TRIVIAL;
return ret;
else
oidclr(&parent_oid);
else
oidclr(&parent_oid);
- t = xcalloc(1, sizeof(struct notes_tree));
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
o->local_ref = local_ref_to_free =
init_notes(t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
o->local_ref = local_ref_to_free =
- it = xcalloc(1, sizeof(*it));
it->next = pbase_tree;
pbase_tree = it;
it->next = pbase_tree;
pbase_tree = it;
progress_state = start_progress(_("Counting objects"),
to_pack.nr_objects);
progress_state = start_progress(_("Counting objects"),
to_pack.nr_objects);
- sorted_by_offset = xcalloc(to_pack.nr_objects, sizeof(struct object_entry *));
+ CALLOC_ARRAY(sorted_by_offset, to_pack.nr_objects);
for (i = 0; i < to_pack.nr_objects; i++)
sorted_by_offset[i] = to_pack.objects + i;
QSORT(sorted_by_offset, to_pack.nr_objects, pack_offset_sort);
for (i = 0; i < to_pack.nr_objects; i++)
sorted_by_offset[i] = to_pack.objects + i;
QSORT(sorted_by_offset, to_pack.nr_objects, pack_offset_sort);
struct unpacked *array;
unsigned long mem_usage = 0;
struct unpacked *array;
unsigned long mem_usage = 0;
- array = xcalloc(window, sizeof(struct unpacked));
+ CALLOC_ARRAY(array, window);
for (;;) {
struct object_entry *entry;
for (;;) {
struct object_entry *entry;
if (progress > pack_to_stdout)
fprintf_ln(stderr, _("Delta compression using up to %d threads"),
delta_search_threads);
if (progress > pack_to_stdout)
fprintf_ln(stderr, _("Delta compression using up to %d threads"),
delta_search_threads);
- p = xcalloc(delta_search_threads, sizeof(*p));
+ CALLOC_ARRAY(p, delta_search_threads);
/* Partition the work amongst work threads. */
for (i = 0; i < delta_search_threads; i++) {
/* Partition the work amongst work threads. */
for (i = 0; i < delta_search_threads; i++) {
return;
/* prepare an array of packed_list for easier sorting */
return;
/* prepare an array of packed_list for easier sorting */
- ary = xcalloc(n, sizeof(struct pack_list *));
for (n = 0, p = *pl; p; p = p->next)
ary[n++] = p;
for (n = 0, p = *pl; p; p = p->next)
ary[n++] = p;
- ref_pattern = xcalloc(1, sizeof(struct proc_receive_ref));
+ CALLOC_ARRAY(ref_pattern, 1);
p = strchr(prefix, ':');
if (p) {
while (prefix < p) {
p = strchr(prefix, ':');
if (p) {
while (prefix < p) {
}
if (new_report) {
if (!hint->report) {
}
if (new_report) {
if (!hint->report) {
- hint->report = xcalloc(1, sizeof(struct ref_push_report));
+ CALLOC_ARRAY(hint->report, 1);
report = hint->report;
} else {
report = hint->report;
report = hint->report;
} else {
report = hint->report;
static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
{
struct obj_buffer *obj;
static void add_object_buffer(struct object *object, char *buffer, unsigned long size)
{
struct obj_buffer *obj;
- obj = xcalloc(1, sizeof(struct obj_buffer));
obj->buffer = buffer;
obj->size = size;
if (add_decoration(&obj_decorate, object, obj))
obj->buffer = buffer;
obj->size = size;
if (add_decoration(&obj_decorate, object, obj))
if (!quiet)
progress = start_progress(_("Unpacking objects"), nr_objects);
if (!quiet)
progress = start_progress(_("Unpacking objects"), nr_objects);
- obj_list = xcalloc(nr_objects, sizeof(*obj_list));
+ CALLOC_ARRAY(obj_list, nr_objects);
for (i = 0; i < nr_objects; i++) {
unpack_one(i);
display_progress(progress, i + 1);
for (i = 0; i < nr_objects; i++) {
unpack_one(i);
display_progress(progress, i + 1);
/* Note: idx is non-NULL when we are writing */
if ((flags & HASH_WRITE_OBJECT) != 0)
/* Note: idx is non-NULL when we are writing */
if ((flags & HASH_WRITE_OBJECT) != 0)
- idx = xcalloc(1, sizeof(*idx));
* hence +2.
*/
it->subtree_alloc = subtree_nr + 2;
* hence +2.
*/
it->subtree_alloc = subtree_nr + 2;
- it->down = xcalloc(it->subtree_alloc, sizeof(struct cache_tree_sub *));
+ CALLOC_ARRAY(it->down, it->subtree_alloc);
for (i = 0; i < subtree_nr; i++) {
/* read each subtree */
struct cache_tree *sub;
for (i = 0; i < subtree_nr; i++) {
/* read each subtree */
struct cache_tree *sub;
* - Else if we have NEW, insert newend lline into base and
* consume newend
*/
* - Else if we have NEW, insert newend lline into base and
* consume newend
*/
- lcs = xcalloc(st_add(origbaselen, 1), sizeof(int*));
- directions = xcalloc(st_add(origbaselen, 1), sizeof(enum coalesce_direction*));
+ CALLOC_ARRAY(lcs, st_add(origbaselen, 1));
+ CALLOC_ARRAY(directions, st_add(origbaselen, 1));
for (i = 0; i < origbaselen + 1; i++) {
for (i = 0; i < origbaselen + 1; i++) {
- lcs[i] = xcalloc(st_add(lennew, 1), sizeof(int));
- directions[i] = xcalloc(st_add(lennew, 1), sizeof(enum coalesce_direction));
+ CALLOC_ARRAY(lcs[i], st_add(lennew, 1));
+ CALLOC_ARRAY(directions[i], st_add(lennew, 1));
directions[i][0] = BASE;
}
for (j = 1; j < lennew + 1; j++)
directions[i][0] = BASE;
}
for (j = 1; j < lennew + 1; j++)
state->lost_bucket = &state->sline[state->nb-1];
}
if (!state->sline[state->nb-1].p_lno)
state->lost_bucket = &state->sline[state->nb-1];
}
if (!state->sline[state->nb-1].p_lno)
- state->sline[state->nb-1].p_lno =
- xcalloc(state->num_parent, sizeof(unsigned long));
+ CALLOC_ARRAY(state->sline[state->nb - 1].p_lno,
+ state->num_parent);
state->sline[state->nb-1].p_lno[state->n] = state->ob;
}
state->sline[state->nb-1].p_lno[state->n] = state->ob;
}
if (result_size && result[result_size-1] != '\n')
cnt++; /* incomplete line */
if (result_size && result[result_size-1] != '\n')
cnt++; /* incomplete line */
- sline = xcalloc(st_add(cnt, 2), sizeof(*sline));
+ CALLOC_ARRAY(sline, st_add(cnt, 2));
sline[0].bol = result;
for (lno = 0, cp = result; cp < result + result_size; cp++) {
if (*cp == '\n') {
sline[0].bol = result;
for (lno = 0, cp = result; cp < result + result_size; cp++) {
if (*cp == '\n') {
/* Even p_lno[cnt+1] is valid -- that is for the end line number
* for deletion hunk at the end.
*/
/* Even p_lno[cnt+1] is valid -- that is for the end line number
* for deletion hunk at the end.
*/
- sline[0].p_lno = xcalloc(st_mult(st_add(cnt, 2), num_parent), sizeof(unsigned long));
+ CALLOC_ARRAY(sline[0].p_lno, st_mult(st_add(cnt, 2), num_parent));
for (lno = 0; lno <= cnt; lno++)
sline[lno+1].p_lno = sline[lno].p_lno + num_parent;
for (lno = 0; lno <= cnt; lno++)
sline[lno+1].p_lno = sline[lno].p_lno + num_parent;
struct diff_filespec *pool;
pair = xmalloc(sizeof(*pair));
struct diff_filespec *pool;
pair = xmalloc(sizeof(*pair));
- pool = xcalloc(st_add(num_parent, 1), sizeof(struct diff_filespec));
+ CALLOC_ARRAY(pool, st_add(num_parent, 1));
pair->one = pool + 1;
pair->two = pool;
pair->one = pool + 1;
pair->two = pool;
struct diff_queue_struct q;
int i;
struct diff_queue_struct q;
int i;
- q.queue = xcalloc(num_paths, sizeof(struct diff_filepair *));
+ CALLOC_ARRAY(q.queue, num_paths);
q.alloc = num_paths;
q.nr = num_paths;
for (i = 0, p = paths; p; p = p->next)
q.alloc = num_paths;
q.nr = num_paths;
for (i = 0, p = paths; p; p = p->next)
return NULL;
count = st.st_size / (the_hash_algo->hexsz + 1);
return NULL;
count = st.st_size / (the_hash_algo->hexsz + 1);
- oids = xcalloc(count, sizeof(struct object_id));
+ CALLOC_ARRAY(oids, count);
if (!commit_graph_compatible(the_repository))
return 0;
if (!commit_graph_compatible(the_repository))
return 0;
- ctx = xcalloc(1, sizeof(struct write_commit_graph_context));
ctx->r = the_repository;
ctx->odb = odb;
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
ctx->r = the_repository;
ctx->odb = odb;
ctx->append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0;
int *filled_index;
int i, j, filled;
int *filled_index;
int i, j, filled;
- work = xcalloc(cnt, sizeof(*work));
+ CALLOC_ARRAY(work, cnt);
redundant = xcalloc(cnt, 1);
ALLOC_ARRAY(filled_index, cnt - 1);
redundant = xcalloc(cnt, 1);
ALLOC_ARRAY(filled_index, cnt - 1);
/* There are more than one */
cnt = commit_list_count(result);
/* There are more than one */
cnt = commit_list_count(result);
- rslt = xcalloc(cnt, sizeof(*rslt));
+ CALLOC_ARRAY(rslt, cnt);
for (list = result, i = 0; list; list = list->next)
rslt[i++] = list->item;
free_commit_list(result);
for (list = result, i = 0; list; list = list->next)
rslt[i++] = list->item;
free_commit_list(result);
p->item->object.flags |= STALE;
num_head++;
}
p->item->object.flags |= STALE;
num_head++;
}
- array = xcalloc(num_head, sizeof(*array));
+ CALLOC_ARRAY(array, num_head);
for (p = heads, i = 0; p; p = p->next) {
if (p->item->object.flags & STALE) {
array[i++] = p->item;
for (p = heads, i = 0; p; p = p->next) {
if (p->item->object.flags & STALE) {
array[i++] = p->item;
* if (verify_signed_buffer(buf, len, buf + len, size - len, ...))
* warn("warning: signed tag unverified.");
*/
* if (verify_signed_buffer(buf, len, buf + len, size - len, ...))
* warn("warning: signed tag unverified.");
*/
- mergetag = xcalloc(1, sizeof(*mergetag));
+ CALLOC_ARRAY(mergetag, 1);
mergetag->key = xstrdup("mergetag");
mergetag->value = buf;
mergetag->len = size;
mergetag->key = xstrdup("mergetag");
mergetag->value = buf;
mergetag->len = size;
excluded_header_field(line, eof - line, exclude))
continue;
excluded_header_field(line, eof - line, exclude))
continue;
- it = xcalloc(1, sizeof(*it));
it->key = xmemdupz(line, eof-line);
*tail = it;
tail = &it->next;
it->key = xmemdupz(line, eof-line);
*tail = it;
tail = &it->next;
opts.git_dir = repo->gitdir;
if (!repo->config)
opts.git_dir = repo->gitdir;
if (!repo->config)
- repo->config = xcalloc(1, sizeof(struct config_set));
+ CALLOC_ARRAY(repo->config, 1);
else
git_configset_clear(repo->config);
else
git_configset_clear(repo->config);
@@
- ptr = xmalloc((n) * sizeof(T));
+ ALLOC_ARRAY(ptr, n);
@@
- ptr = xmalloc((n) * sizeof(T));
+ ALLOC_ARRAY(ptr, n);
+
+@@
+type T;
+T *ptr;
+expression n;
+@@
+- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \) )
++ CALLOC_ARRAY(ptr, n)
if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
break;
if (!drv) {
if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
break;
if (!drv) {
- drv = xcalloc(1, sizeof(struct convert_driver));
drv->name = xmemdupz(name, namelen);
*user_convert_tail = drv;
user_convert_tail = &(drv->next);
drv->name = xmemdupz(name, namelen);
*user_convert_tail = drv;
user_convert_tail = &(drv->next);
{
struct child *newborn, **cradle;
{
struct child *newborn, **cradle;
- newborn = xcalloc(1, sizeof(*newborn));
+ CALLOC_ARRAY(newborn, 1);
live_children++;
memcpy(&newborn->cld, cld, sizeof(*cld));
memcpy(&newborn->address, addr, addrlen);
live_children++;
memcpy(&newborn->cld, cld, sizeof(*cld));
memcpy(&newborn->address, addr, addrlen);
struct pollfd *pfd;
int i;
struct pollfd *pfd;
int i;
- pfd = xcalloc(socklist->nr, sizeof(struct pollfd));
+ CALLOC_ARRAY(pfd, socklist->nr);
for (i = 0; i < socklist->nr; i++) {
pfd[i].fd = socklist->list[i];
for (i = 0; i < socklist->nr; i++) {
pfd[i].fd = socklist->list[i];
struct decoration_entry *old_entries = n->entries;
n->size = (old_size + 1000) * 3 / 2;
struct decoration_entry *old_entries = n->entries;
n->size = (old_size + 1000) * 3 / 2;
- n->entries = xcalloc(n->size, sizeof(struct decoration_entry));
+ CALLOC_ARRAY(n->entries, n->size);
n->nr = 0;
for (i = 0; i < old_size; i++) {
n->nr = 0;
for (i = 0; i < old_size; i++) {
struct diff_options *o = xmalloc(sizeof(struct diff_options));
memcpy(o, orig_opts, sizeof(struct diff_options));
struct diff_options *o = xmalloc(sizeof(struct diff_options));
memcpy(o, orig_opts, sizeof(struct diff_options));
- ecbdata->diff_words =
- xcalloc(1, sizeof(struct diff_words_data));
+ CALLOC_ARRAY(ecbdata->diff_words, 1);
ecbdata->diff_words->type = o->word_diff;
ecbdata->diff_words->opt = o;
if (orig_opts->emitted_symbols)
ecbdata->diff_words->type = o->word_diff;
ecbdata->diff_words->opt = o;
if (orig_opts->emitted_symbols)
- o->emitted_symbols =
- xcalloc(1, sizeof(struct emitted_diff_symbols));
+ CALLOC_ARRAY(o->emitted_symbols, 1);
if (!o->word_regex)
o->word_regex = userdiff_word_regex(one, o->repo->index);
if (!o->word_regex)
o->word_regex = userdiff_word_regex(one, o->repo->index);
const char *name_b)
{
struct diffstat_file *x;
const char *name_b)
{
struct diffstat_file *x;
- x = xcalloc(1, sizeof(*x));
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
diffstat->files[diffstat->nr++] = x;
if (name_b) {
ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
diffstat->files[diffstat->nr++] = x;
if (name_b) {
return error(_("unable to resolve '%s'"), arg);
if (!opt->objfind)
return error(_("unable to resolve '%s'"), arg);
if (!opt->objfind)
- opt->objfind = xcalloc(1, sizeof(*opt->objfind));
+ CALLOC_ARRAY(opt->objfind, 1);
opt->pickaxe_opts |= DIFF_PICKAXE_KIND_OBJFIND;
opt->flags.recursive = 1;
opt->pickaxe_opts |= DIFF_PICKAXE_KIND_OBJFIND;
opt->flags.recursive = 1;
(uint64_t)num_destinations * (uint64_t)num_sources);
}
(uint64_t)num_destinations * (uint64_t)num_sources);
}
- mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_destinations),
- sizeof(*mx));
+ CALLOC_ARRAY(mx, st_mult(NUM_CANDIDATE_PER_DST, num_destinations));
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
struct diff_filespec *two = rename_dst[i].p->two;
struct diff_score *m;
for (dst_cnt = i = 0; i < rename_dst_nr; i++) {
struct diff_filespec *two = rename_dst[i].p->two;
struct diff_score *m;
const char *cp;
struct oid_stat oid_stat;
const char *cp;
struct oid_stat oid_stat;
- stk = xcalloc(1, sizeof(*stk));
if (current < 0) {
cp = base;
current = 0;
if (current < 0) {
cp = base;
current = 0;
int varint_len;
const unsigned hashsz = the_hash_algo->rawsz;
int varint_len;
const unsigned hashsz = the_hash_algo->rawsz;
- ouc = xcalloc(1, sizeof(*ouc));
stat_data_to_disk(&ouc->info_exclude_stat, &untracked->ss_info_exclude.stat);
stat_data_to_disk(&ouc->excludes_file_stat, &untracked->ss_excludes_file.stat);
ouc->dir_flags = htonl(untracked->dir_flags);
stat_data_to_disk(&ouc->info_exclude_stat, &untracked->ss_info_exclude.stat);
stat_data_to_disk(&ouc->excludes_file_stat, &untracked->ss_excludes_file.stat);
ouc->dir_flags = htonl(untracked->dir_flags);
if (next + exclude_per_dir_offset + 1 > end)
return NULL;
if (next + exclude_per_dir_offset + 1 > end)
return NULL;
- uc = xcalloc(1, sizeof(*uc));
strbuf_init(&uc->ident, ident_len);
strbuf_add(&uc->ident, ident, ident_len);
load_oid_stat(&uc->ss_info_exclude,
strbuf_init(&uc->ident, ident_len);
strbuf_add(&uc->ident, ident, ident_len);
load_oid_stat(&uc->ss_info_exclude,
struct bitmap *bitmap_word_alloc(size_t word_alloc)
{
struct bitmap *bitmap = xmalloc(sizeof(struct bitmap));
struct bitmap *bitmap_word_alloc(size_t word_alloc)
{
struct bitmap *bitmap = xmalloc(sizeof(struct bitmap));
- bitmap->words = xcalloc(word_alloc, sizeof(eword_t));
+ CALLOC_ARRAY(bitmap->words, word_alloc);
bitmap->word_alloc = word_alloc;
return bitmap;
}
bitmap->word_alloc = word_alloc;
return bitmap;
}
* remote is also shallow, check what ref is safe to update
* without updating .git/shallow
*/
* remote is also shallow, check what ref is safe to update
* without updating .git/shallow
*/
- status = xcalloc(nr_sought, sizeof(*status));
+ CALLOC_ARRAY(status, nr_sought);
assign_shallow_commits_to_refs(si, NULL, status);
if (si->nr_ours || si->nr_theirs) {
for (i = 0; i < nr_sought; i++)
assign_shallow_commits_to_refs(si, NULL, status);
if (si->nr_ours || si->nr_theirs) {
for (i = 0; i < nr_sought; i++)
if (!find_merge_parent(merge_parents, &oid, NULL))
return 0; /* subsumed by other parents */
if (!find_merge_parent(merge_parents, &oid, NULL))
return 0; /* subsumed by other parents */
- origin_data = xcalloc(1, sizeof(struct origin_data));
+ CALLOC_ARRAY(origin_data, 1);
oidcpy(&origin_data->oid, &oid);
if (line[len - 1] == '\n')
oidcpy(&origin_data->oid, &oid);
if (line[len - 1] == '\n')
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
case GREP_PATTERN_BODY:
case GREP_PATTERN: /* atom */
case GREP_PATTERN_HEAD:
case GREP_PATTERN_BODY:
- x = xcalloc(1, sizeof (struct grep_expr));
x->node = GREP_NODE_ATOM;
x->u.atom = p;
*list = p->next;
x->node = GREP_NODE_ATOM;
x->u.atom = p;
*list = p->next;
if (!p->next)
die("--not not followed by pattern expression");
*list = p->next;
if (!p->next)
die("--not not followed by pattern expression");
*list = p->next;
- x = xcalloc(1, sizeof (struct grep_expr));
x->node = GREP_NODE_NOT;
x->u.unary = compile_pattern_not(list);
if (!x->u.unary)
x->node = GREP_NODE_NOT;
x->u.unary = compile_pattern_not(list);
if (!x->u.unary)
y = compile_pattern_and(list);
if (!y)
die("--and not followed by pattern expression");
y = compile_pattern_and(list);
if (!y)
die("--and not followed by pattern expression");
- z = xcalloc(1, sizeof (struct grep_expr));
z->node = GREP_NODE_AND;
z->u.binary.left = x;
z->u.binary.right = y;
z->node = GREP_NODE_AND;
z->u.binary.left = x;
z->u.binary.right = y;
y = compile_pattern_or(list);
if (!y)
die("not a pattern expression %s", p->pattern);
y = compile_pattern_or(list);
if (!y)
die("not a pattern expression %s", p->pattern);
- z = xcalloc(1, sizeof (struct grep_expr));
z->node = GREP_NODE_OR;
z->u.binary.left = x;
z->u.binary.right = y;
z->node = GREP_NODE_OR;
z->u.binary.left = x;
z->u.binary.right = y;
static void alloc_table(struct hashmap *map, unsigned int size)
{
map->tablesize = size;
static void alloc_table(struct hashmap *map, unsigned int size)
{
map->tablesize = size;
- map->table = xcalloc(size, sizeof(struct hashmap_entry *));
+ CALLOC_ARRAY(map->table, size);
/* calculate resize thresholds for new size */
map->grow_at = (unsigned int) ((uint64_t) size * HASHMAP_LOAD_FACTOR / 100);
/* calculate resize thresholds for new size */
map->grow_at = (unsigned int) ((uint64_t) size * HASHMAP_LOAD_FACTOR / 100);
if (!query_params) {
const char *query = getenv("QUERY_STRING");
if (!query_params) {
const char *query = getenv("QUERY_STRING");
- query_params = xcalloc(1, sizeof(*query_params));
+ CALLOC_ARRAY(query_params, 1);
while (query && *query) {
char *name = url_decode_parameter_name(&query);
char *value = url_decode_parameter_value(&query);
while (query && *query) {
char *name = url_decode_parameter_name(&query);
char *value = url_decode_parameter_value(&query);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, dav_headers);
curl_easy_setopt(slot->curl, CURLOPT_FILE, &in_buffer);
- lock = xcalloc(1, sizeof(*lock));
lock->timeout = -1;
if (start_active_slot(slot)) {
lock->timeout = -1;
if (start_active_slot(slot)) {
int new_refs;
struct ref *ref, *local_refs;
int new_refs;
struct ref *ref, *local_refs;
- repo = xcalloc(1, sizeof(*repo));
argv++;
for (i = 1; i < argc; i++, argv++) {
argv++;
for (i = 1; i < argc; i++, argv++) {
off_t prev_posn = 0;
struct http_pack_request *preq;
off_t prev_posn = 0;
struct http_pack_request *preq;
- preq = xcalloc(1, sizeof(*preq));
strbuf_init(&preq->tmpfile, 0);
preq->url = url;
strbuf_init(&preq->tmpfile, 0);
preq->url = url;
off_t prev_posn = 0;
struct http_object_request *freq;
off_t prev_posn = 0;
struct http_object_request *freq;
- freq = xcalloc(1, sizeof(*freq));
strbuf_init(&freq->tmpfile, 0);
oidcpy(&freq->oid, oid);
freq->localfile = -1;
strbuf_init(&freq->tmpfile, 0);
oidcpy(&freq->oid, oid);
freq->localfile = -1;
char *arg, *rsp;
int s = -1, preauth;
char *arg, *rsp;
int s = -1, preauth;
- ctx = xcalloc(1, sizeof(*ctx));
- ctx->imap = imap = xcalloc(1, sizeof(*imap));
+ ctx->imap = CALLOC_ARRAY(imap, 1);
imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
imap->in_progress_append = &imap->in_progress;
imap->buf.sock.fd[0] = imap->buf.sock.fd[1] = -1;
imap->in_progress_append = &imap->in_progress;
- p = xcalloc(1, sizeof(struct line_log_data));
p->path = path;
range_set_append(&p->ranges, begin, end);
if (ip) {
p->path = path;
range_set_append(&p->ranges, begin, end);
if (ip) {
drv = userdiff_find_by_path(istate, path);
if (drv && drv->funcname.pattern) {
const struct userdiff_funcname *pe = &drv->funcname;
drv = userdiff_find_by_path(istate, path);
if (drv && drv->funcname.pattern) {
const struct userdiff_funcname *pe = &drv->funcname;
- xecfg = xcalloc(1, sizeof(*xecfg));
+ CALLOC_ARRAY(xecfg, 1);
xdiff_set_find_func(xecfg, pe->pattern, pe->cflags);
}
xdiff_set_find_func(xecfg, pe->pattern, pe->cflags);
}
seen_info = oidmap_get(
&filter_data->seen_at_depth, &obj->oid);
if (!seen_info) {
seen_info = oidmap_get(
&filter_data->seen_at_depth, &obj->oid);
if (!seen_info) {
- seen_info = xcalloc(1, sizeof(*seen_info));
+ CALLOC_ARRAY(seen_info, 1);
oidcpy(&seen_info->base.oid, &obj->oid);
seen_info->depth = filter_data->current_depth;
oidmap_put(&filter_data->seen_at_depth, seen_info);
oidcpy(&seen_info->base.oid, &obj->oid);
seen_info->depth = filter_data->current_depth;
oidmap_put(&filter_data->seen_at_depth, seen_info);
size_t sub;
d->nr = filter_options->sub_nr;
size_t sub;
d->nr = filter_options->sub_nr;
- d->sub = xcalloc(d->nr, sizeof(*d->sub));
+ CALLOC_ARRAY(d->sub, d->nr);
for (sub = 0; sub < d->nr; sub++)
d->sub[sub].filter = list_objects_filter__init(
filter->omits ? &d->sub[sub].omits : NULL,
for (sub = 0; sub < d->nr; sub++)
d->sub[sub].filter = list_objects_filter__init(
filter->omits ? &d->sub[sub].omits : NULL,
if (!init_fn)
return NULL;
if (!init_fn)
return NULL;
- filter = xcalloc(1, sizeof(*filter));
+ CALLOC_ARRAY(filter, 1);
filter->omits = omitted;
init_fn(filter_options, filter);
return filter;
filter->omits = omitted;
init_fn(filter_options, filter);
return filter;
if (!strncmp(fn->name, name, namelen) && !fn->name[namelen])
break;
if (!fn) {
if (!strncmp(fn->name, name, namelen) && !fn->name[namelen])
break;
if (!fn) {
- fn = xcalloc(1, sizeof(struct ll_merge_driver));
fn->name = xmemdupz(name, namelen);
fn->fn = ll_ext_merge;
*ll_user_merge_tail = fn;
fn->name = xmemdupz(name, namelen);
fn->fn = ll_ext_merge;
*ll_user_merge_tail = fn;
if (item->util) {
me = (struct mailmap_entry *)item->util;
} else {
if (item->util) {
me = (struct mailmap_entry *)item->util;
} else {
- me = xcalloc(1, sizeof(struct mailmap_entry));
me->namemap.strdup_strings = 1;
me->namemap.cmp = namemap_cmp;
item->util = me;
me->namemap.strdup_strings = 1;
me->namemap.cmp = namemap_cmp;
item->util = me;
if (collision_info) {
free(new_path);
} else {
if (collision_info) {
free(new_path);
} else {
- collision_info = xcalloc(1,
- sizeof(struct collision_info));
+ CALLOC_ARRAY(collision_info, 1);
string_list_init(&collision_info->source_files, 0);
strmap_put(collisions, new_path, collision_info);
}
string_list_init(&collision_info->source_files, 0);
strmap_put(collisions, new_path, collision_info);
}
struct conflict_info *dir_ci;
char *cur_dir = dirs_to_insert.items[i].string;
struct conflict_info *dir_ci;
char *cur_dir = dirs_to_insert.items[i].string;
- dir_ci = xcalloc(1, sizeof(*dir_ci));
+ CALLOC_ARRAY(dir_ci, 1);
dir_ci->merged.directory_name = parent_name;
len = strlen(parent_name);
dir_ci->merged.directory_name = parent_name;
len = strlen(parent_name);
* the directory to remain here, so we need to move this
* path to some new location.
*/
* the directory to remain here, so we need to move this
* path to some new location.
*/
- new_ci = xcalloc(1, sizeof(*new_ci));
+ CALLOC_ARRAY(new_ci, 1);
/* We don't really want new_ci->merged.result copied, but it'll
* be overwritten below so it doesn't matter. We also don't
* want any directory mode/oid values copied, but we'll zero
/* We don't really want new_ci->merged.result copied, but it'll
* be overwritten below so it doesn't matter. We also don't
* want any directory mode/oid values copied, but we'll zero
unpack_opts.verbose_update = (opt->verbosity > 2);
unpack_opts.fn = twoway_merge;
if (1/* FIXME: opts->overwrite_ignore*/) {
unpack_opts.verbose_update = (opt->verbosity > 2);
unpack_opts.fn = twoway_merge;
if (1/* FIXME: opts->overwrite_ignore*/) {
- unpack_opts.dir = xcalloc(1, sizeof(*unpack_opts.dir));
+ CALLOC_ARRAY(unpack_opts.dir, 1);
unpack_opts.dir->flags |= DIR_SHOW_IGNORED;
setup_standard_excludes(unpack_opts.dir);
}
unpack_opts.dir->flags |= DIR_SHOW_IGNORED;
setup_standard_excludes(unpack_opts.dir);
}
- ci = xcalloc(1, sizeof(struct rename_conflict_info));
ci->rename_type = rename_type;
ci->ren1 = ren1;
ci->ren2 = ren2;
ci->rename_type = rename_type;
ci->ren1 = ren1;
ci->ren2 = ren2;
continue;
collision_ent = collision_find_entry(collisions, new_path);
if (!collision_ent) {
continue;
collision_ent = collision_find_entry(collisions, new_path);
if (!collision_ent) {
- collision_ent = xcalloc(1,
- sizeof(struct collision_entry));
+ CALLOC_ARRAY(collision_ent, 1);
hashmap_entry_init(&collision_ent->ent,
strhash(new_path));
hashmap_put(collisions, &collision_ent->ent);
hashmap_entry_init(&collision_ent->ent,
strhash(new_path));
hashmap_put(collisions, &collision_ent->ent);
struct string_list *renames;
compute_collisions(&collisions, dir_renames, pairs);
struct string_list *renames;
compute_collisions(&collisions, dir_renames, pairs);
- renames = xcalloc(1, sizeof(struct string_list));
+ CALLOC_ARRAY(renames, 1);
for (i = 0; i < pairs->nr; ++i) {
struct string_list_item *item;
for (i = 0; i < pairs->nr; ++i) {
struct string_list_item *item;
- opt->priv = xcalloc(1, sizeof(*opt->priv));
+ CALLOC_ARRAY(opt->priv, 1);
string_list_init(&opt->priv->df_conflict_file_set, 1);
return 0;
}
string_list_init(&opt->priv->df_conflict_file_set, 1);
return 0;
}
m->num_objects = ntohl(m->chunk_oid_fanout[255]);
m->num_objects = ntohl(m->chunk_oid_fanout[255]);
- m->pack_names = xcalloc(m->num_packs, sizeof(*m->pack_names));
- m->packs = xcalloc(m->num_packs, sizeof(*m->packs));
+ CALLOC_ARRAY(m->pack_names, m->num_packs);
+ CALLOC_ARRAY(m->packs, m->num_packs);
cur_pack_name = (const char *)m->chunk_pack_names;
for (i = 0; i < m->num_packs; i++) {
cur_pack_name = (const char *)m->chunk_pack_names;
for (i = 0; i < m->num_packs; i++) {
- count = xcalloc(m->num_packs, sizeof(uint32_t));
+ CALLOC_ARRAY(count, m->num_packs);
if (flags & MIDX_PROGRESS)
progress = start_delayed_progress(_("Counting referenced objects"),
if (flags & MIDX_PROGRESS)
progress = start_delayed_progress(_("Counting referenced objects"),
- include_pack = xcalloc(m->num_packs, sizeof(unsigned char));
+ CALLOC_ARRAY(include_pack, m->num_packs);
if (batch_size) {
if (fill_included_packs_batch(r, m, include_pack, batch_size))
if (batch_size) {
if (fill_included_packs_batch(r, m, include_pack, batch_size))
- lazy_dir_mutex_array = xcalloc(LAZY_MAX_MUTEX, sizeof(pthread_mutex_t));
+ CALLOC_ARRAY(lazy_dir_mutex_array, LAZY_MAX_MUTEX);
for (j = 0; j < LAZY_MAX_MUTEX; j++)
init_recursive_mutex(&lazy_dir_mutex_array[j]);
for (j = 0; j < LAZY_MAX_MUTEX; j++)
init_recursive_mutex(&lazy_dir_mutex_array[j]);
k_start = 0;
nr_each = DIV_ROUND_UP(istate->cache_nr, lazy_nr_dir_threads);
k_start = 0;
nr_each = DIV_ROUND_UP(istate->cache_nr, lazy_nr_dir_threads);
- lazy_entries = xcalloc(istate->cache_nr, sizeof(struct lazy_entry));
- td_dir = xcalloc(lazy_nr_dir_threads, sizeof(struct lazy_dir_thread_data));
- td_name = xcalloc(1, sizeof(struct lazy_name_thread_data));
+ CALLOC_ARRAY(lazy_entries, istate->cache_nr);
+ CALLOC_ARRAY(td_dir, lazy_nr_dir_threads);
+ CALLOC_ARRAY(td_name, 1);
negotiator->next = next;
negotiator->ack = ack;
negotiator->release = release;
negotiator->next = next;
negotiator->ack = ack;
negotiator->release = release;
- negotiator->data = ns = xcalloc(1, sizeof(*ns));
+ negotiator->data = CALLOC_ARRAY(ns, 1);
ns->rev_list.compare = compare_commits_by_commit_date;
if (marked)
ns->rev_list.compare = compare_commits_by_commit_date;
if (marked)
struct entry *entry;
commit->object.flags |= mark | SEEN;
struct entry *entry;
commit->object.flags |= mark | SEEN;
- entry = xcalloc(1, sizeof(*entry));
+ CALLOC_ARRAY(entry, 1);
entry->commit = commit;
prio_queue_put(&data->rev_list, entry);
entry->commit = commit;
prio_queue_put(&data->rev_list, entry);
negotiator->next = next;
negotiator->ack = ack;
negotiator->release = release;
negotiator->next = next;
negotiator->ack = ack;
negotiator->release = release;
- negotiator->data = data = xcalloc(1, sizeof(*data));
+ negotiator->data = CALLOC_ARRAY(data, 1);
data->rev_list.compare = compare;
if (marked)
data->rev_list.compare = compare;
if (marked)
diff_tree_oid(base, remote, "", &opt);
diffcore_std(&opt);
diff_tree_oid(base, remote, "", &opt);
diffcore_std(&opt);
- changes = xcalloc(diff_queued_diff.nr, sizeof(struct notes_merge_pair));
+ CALLOC_ARRAY(changes, diff_queued_diff.nr);
for (i = 0; i < diff_queued_diff.nr; i++) {
struct diff_filepair *p = diff_queued_diff.queue[i];
for (i = 0; i < diff_queued_diff.nr; i++) {
struct diff_filepair *p = diff_queued_diff.queue[i];
c->cmd = cmd;
c->enabled = 1;
c->combine = combine_notes_concatenate;
c->cmd = cmd;
c->enabled = 1;
c->combine = combine_notes_concatenate;
- c->refs = xcalloc(1, sizeof(struct string_list));
+ CALLOC_ARRAY(c->refs, 1);
c->refs->strdup_strings = 1;
c->refs_from_env = 0;
c->mode_from_env = 0;
c->refs->strdup_strings = 1;
c->refs_from_env = 0;
c->mode_from_env = 0;
- l = xcalloc(1, sizeof(*l));
oidcpy(&l->key_oid, &object_oid);
oidcpy(&l->val_oid, &entry.oid);
if (note_tree_insert(t, node, n, l, type,
oidcpy(&l->key_oid, &object_oid);
oidcpy(&l->val_oid, &entry.oid);
if (note_tree_insert(t, node, n, l, type,
- ent = xcalloc(1, sizeof(*ent));
ent->path = xstrdup(pathbuf.buf);
/* add the alternate entry */
ent->path = xstrdup(pathbuf.buf);
/* add the alternate entry */
int new_hash_size = r->parsed_objects->obj_hash_size < 32 ? 32 : 2 * r->parsed_objects->obj_hash_size;
struct object **new_hash;
int new_hash_size = r->parsed_objects->obj_hash_size < 32 ? 32 : 2 * r->parsed_objects->obj_hash_size;
struct object **new_hash;
- new_hash = xcalloc(new_hash_size, sizeof(struct object *));
+ CALLOC_ARRAY(new_hash, new_hash_size);
for (i = 0; i < r->parsed_objects->obj_hash_size; i++) {
struct object *obj = r->parsed_objects->obj_hash[i];
for (i = 0; i < r->parsed_objects->obj_hash_size; i++) {
struct object *obj = r->parsed_objects->obj_hash[i];
o->object_state = allocate_alloc_state();
o->is_shallow = -1;
o->object_state = allocate_alloc_state();
o->is_shallow = -1;
- o->shallow_stat = xcalloc(1, sizeof(*o->shallow_stat));
+ CALLOC_ARRAY(o->shallow_stat, 1);
o->buffer_slab = allocate_commit_buffer_slab();
o->buffer_slab = allocate_commit_buffer_slab();
/* try to open a bitmapped pack, but don't parse it yet
* because we may not need to use it */
/* try to open a bitmapped pack, but don't parse it yet
* because we may not need to use it */
- bitmap_git = xcalloc(1, sizeof(*bitmap_git));
+ CALLOC_ARRAY(bitmap_git, 1);
if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
goto cleanup;
if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
goto cleanup;
uint32_t *reposition;
num_objects = bitmap_git->pack->num_objects;
uint32_t *reposition;
num_objects = bitmap_git->pack->num_objects;
- reposition = xcalloc(num_objects, sizeof(uint32_t));
+ CALLOC_ARRAY(reposition, num_objects);
for (i = 0; i < num_objects; ++i) {
struct object_id oid;
for (i = 0; i < num_objects; ++i) {
struct object_id oid;
pdata->index_size = 1024;
free(pdata->index);
pdata->index_size = 1024;
free(pdata->index);
- pdata->index = xcalloc(pdata->index_size, sizeof(*pdata->index));
+ CALLOC_ARRAY(pdata->index, pdata->index_size);
if (p->pack_fd == -1 && open_packed_git(p))
die("packfile %s cannot be accessed", p->pack_name);
if (p->pack_fd == -1 && open_packed_git(p))
die("packfile %s cannot be accessed", p->pack_name);
- win = xcalloc(1, sizeof(*win));
win->offset = (offset / window_align) * window_align;
len = p->pack_size - win->offset;
if (len > packed_git_window_size)
win->offset = (offset / window_align) * window_align;
len = p->pack_size - win->offset;
if (len > packed_git_window_size)
if (!patch_id_defined(commit))
return NULL;
if (!patch_id_defined(commit))
return NULL;
- key = xcalloc(1, sizeof(*key));
if (init_patch_id_entry(key, commit, ids)) {
free(key);
return NULL;
if (init_patch_id_entry(key, commit, ids)) {
free(key);
return NULL;
string_list_remove_empty_items(&list, 0);
item->attr_check = attr_check_alloc();
string_list_remove_empty_items(&list, 0);
item->attr_check = attr_check_alloc();
- item->attr_match = xcalloc(list.nr, sizeof(struct attr_match));
+ CALLOC_ARRAY(item->attr_match, list.nr);
for_each_string_list_item(si, &list) {
size_t attr_len;
for_each_string_list_item(si, &list) {
size_t attr_len;
if (!(flags & PATHSPEC_PREFER_CWD))
BUG("PATHSPEC_PREFER_CWD requires arguments");
if (!(flags & PATHSPEC_PREFER_CWD))
BUG("PATHSPEC_PREFER_CWD requires arguments");
- pathspec->items = item = xcalloc(1, sizeof(*item));
+ pathspec->items = CALLOC_ARRAY(item, 1);
item->match = xstrdup(prefix);
item->original = xstrdup(prefix);
item->nowildcard_len = item->len = strlen(prefix);
item->match = xstrdup(prefix);
item->original = xstrdup(prefix);
item->nowildcard_len = item->len = strlen(prefix);
{
static struct string_list *mail_map;
if (!mail_map) {
{
static struct string_list *mail_map;
if (!mail_map) {
- mail_map = xcalloc(1, sizeof(*mail_map));
+ CALLOC_ARRAY(mail_map, 1);
read_mailmap(mail_map);
}
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
read_mailmap(mail_map);
}
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
now_ns = progress_getnanotime(progress);
if (!tp) {
now_ns = progress_getnanotime(progress);
if (!tp) {
- progress->throughput = tp = xcalloc(1, sizeof(*tp));
+ progress->throughput = CALLOC_ARRAY(tp, 1);
tp->prev_total = tp->curr_total = total;
tp->prev_ns = now_ns;
strbuf_init(&tp->display, 0);
tp->prev_total = tp->curr_total = total;
tp->prev_ns = now_ns;
strbuf_init(&tp->display, 0);
if (remaining_nr) {
int j = 0;
if (remaining_nr) {
int j = 0;
- new_oids = xcalloc(remaining_nr, sizeof(*new_oids));
+ CALLOC_ARRAY(new_oids, remaining_nr);
for (i = 0; i < oid_nr; i++)
if (remaining[i])
oidcpy(&new_oids[j++], &old_oids[i]);
for (i = 0; i < oid_nr; i++)
if (remaining[i])
oidcpy(&new_oids[j++], &old_oids[i]);
string_list_append(list, buf.buf)->util = util;
strbuf_reset(&buf);
}
string_list_append(list, buf.buf)->util = util;
strbuf_reset(&buf);
}
- util = xcalloc(sizeof(*util), 1);
if (get_oid(p, &util->oid)) {
error(_("could not parse commit '%s'"), p);
free(util);
if (get_oid(p, &util->oid)) {
error(_("could not parse commit '%s'"), p);
free(util);
/* ensure we have no more threads than we have blocks to process */
if (nr_threads > ieot->nr)
nr_threads = ieot->nr;
/* ensure we have no more threads than we have blocks to process */
if (nr_threads > ieot->nr)
nr_threads = ieot->nr;
- data = xcalloc(nr_threads, sizeof(*data));
+ CALLOC_ARRAY(data, nr_threads);
offset = ieot_start = 0;
ieot_blocks = DIV_ROUND_UP(ieot->nr, nr_threads);
offset = ieot_start = 0;
ieot_blocks = DIV_ROUND_UP(ieot->nr, nr_threads);
istate->version = ntohl(hdr->hdr_version);
istate->cache_nr = ntohl(hdr->hdr_entries);
istate->cache_alloc = alloc_nr(istate->cache_nr);
istate->version = ntohl(hdr->hdr_version);
istate->cache_nr = ntohl(hdr->hdr_entries);
istate->cache_alloc = alloc_nr(istate->cache_nr);
- istate->cache = xcalloc(istate->cache_alloc, sizeof(*istate->cache));
+ CALLOC_ARRAY(istate->cache, istate->cache_alloc);
istate->initialized = 1;
p.istate = istate;
istate->initialized = 1;
p.istate = istate;
if (split_index->base)
discard_index(split_index->base);
else
if (split_index->base)
discard_index(split_index->base);
else
- split_index->base = xcalloc(1, sizeof(*split_index->base));
+ CALLOC_ARRAY(split_index->base, 1);
base_oid_hex = oid_to_hex(&split_index->base_oid);
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
base_oid_hex = oid_to_hex(&split_index->base_oid);
base_path = xstrfmt("%s/sharedindex.%s", gitdir, base_oid_hex);
stat_validity_clear(sv);
else {
if (!sv->sd)
stat_validity_clear(sv);
else {
if (!sv->sd)
- sv->sd = xcalloc(1, sizeof(struct stat_data));
+ CALLOC_ARRAY(sv->sd, 1);
fill_stat_data(sv->sd, &st);
}
}
fill_stat_data(sv->sd, &st);
}
}
int i;
struct object_info empty = OBJECT_INFO_INIT;
int i;
struct object_info empty = OBJECT_INFO_INIT;
- ref->value = xcalloc(used_atom_cnt, sizeof(struct atom_value));
+ CALLOC_ARRAY(ref->value, used_atom_cnt);
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
if (need_symref && (ref->flag & REF_ISSYMREF) && !ref->symref) {
ref->symref = resolve_refdup(ref->refname, RESOLVE_REF_READING,
if (!check_reachable)
return;
if (!check_reachable)
return;
- to_clear = xcalloc(sizeof(struct commit *), array->nr);
+ CALLOC_ARRAY(to_clear, array->nr);
repo_init_revisions(the_repository, &revs, NULL);
repo_init_revisions(the_repository, &revs, NULL);
- s = xcalloc(1, sizeof(*s));
s->next = *sorting_tail;
*sorting_tail = s;
s->next = *sorting_tail;
*sorting_tail = s;
void init_reflog_walk(struct reflog_walk_info **info)
{
void init_reflog_walk(struct reflog_walk_info **info)
{
- *info = xcalloc(1, sizeof(struct reflog_walk_info));
+ CALLOC_ARRAY(*info, 1);
(*info)->complete_reflogs.strdup_strings = 1;
}
(*info)->complete_reflogs.strdup_strings = 1;
}
- commit_reflog = xcalloc(1, sizeof(struct commit_reflog));
+ CALLOC_ARRAY(commit_reflog, 1);
if (recno < 0) {
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
if (commit_reflog->recno < 0) {
if (recno < 0) {
commit_reflog->recno = get_reflog_recno_by_time(reflogs, timestamp);
if (commit_reflog->recno < 0) {
struct ref_transaction *tr;
assert(err);
struct ref_transaction *tr;
assert(err);
- tr = xcalloc(1, sizeof(struct ref_transaction));
tr->ref_store = refs;
return tr;
}
tr->ref_store = refs;
return tr;
}
while (len && ref[len - 1] == '/')
ref[--len] = '\0';
if (!hide_refs) {
while (len && ref[len - 1] == '/')
ref[--len] = '\0';
if (!hide_refs) {
- hide_refs = xcalloc(1, sizeof(*hide_refs));
+ CALLOC_ARRAY(hide_refs, 1);
hide_refs->strdup_strings = 1;
}
string_list_append(hide_refs, ref);
hide_refs->strdup_strings = 1;
}
string_list_append(hide_refs, ref);
/* First lock the file so it can't change out from under us. */
/* First lock the file so it can't change out from under us. */
- *lock_p = lock = xcalloc(1, sizeof(*lock));
+ *lock_p = CALLOC_ARRAY(lock, 1);
lock->ref_name = xstrdup(refname);
files_ref_path(refs, &ref_file, refname);
lock->ref_name = xstrdup(refname);
files_ref_path(refs, &ref_file, refname);
overlay_iter = overlay_ref_iterator_begin(loose_iter, packed_iter);
overlay_iter = overlay_ref_iterator_begin(loose_iter, packed_iter);
- iter = xcalloc(1, sizeof(*iter));
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &files_ref_iterator_vtable,
overlay_iter->ordered);
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &files_ref_iterator_vtable,
overlay_iter->ordered);
files_assert_main_repository(refs, "lock_ref_oid_basic");
assert(err);
files_assert_main_repository(refs, "lock_ref_oid_basic");
assert(err);
- lock = xcalloc(1, sizeof(struct ref_lock));
if (mustexist)
resolve_flags |= RESOLVE_REF_READING;
if (mustexist)
resolve_flags |= RESOLVE_REF_READING;
return empty_ref_iterator_begin();
}
return empty_ref_iterator_begin();
}
- iter = xcalloc(1, sizeof(*iter));
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &files_reflog_iterator_vtable, 0);
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &files_reflog_iterator_vtable, 0);
if (!transaction->nr)
goto cleanup;
if (!transaction->nr)
goto cleanup;
- backend_data = xcalloc(1, sizeof(*backend_data));
+ CALLOC_ARRAY(backend_data, 1);
transaction->backend_data = backend_data;
/*
transaction->backend_data = backend_data;
/*
if (!*prefix && !trim)
return iter0; /* optimization: no need to wrap iterator */
if (!*prefix && !trim)
return iter0; /* optimization: no need to wrap iterator */
- iter = xcalloc(1, sizeof(*iter));
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &prefix_ref_iterator_vtable, iter0->ordered);
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &prefix_ref_iterator_vtable, iter0->ordered);
if (start == snapshot->eof)
return empty_ref_iterator_begin();
if (start == snapshot->eof)
return empty_ref_iterator_begin();
- iter = xcalloc(1, sizeof(*iter));
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable, 1);
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &packed_ref_iterator_vtable, 1);
- data = xcalloc(1, sizeof(*data));
string_list_init(&data->updates, 0);
transaction->backend_data = data;
string_list_init(&data->updates, 0);
transaction->backend_data = data;
if (prime_dir)
prime_ref_dir(dir, prefix);
if (prime_dir)
prime_ref_dir(dir, prefix);
- iter = xcalloc(1, sizeof(*iter));
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable, 1);
ALLOC_GROW(iter->levels, 10, iter->levels_alloc);
ref_iterator = &iter->base;
base_ref_iterator_init(ref_iterator, &cache_ref_iterator_vtable, 1);
ALLOC_GROW(iter->levels, 10, iter->levels_alloc);
if (e)
return container_of(e, struct remote, ent);
if (e)
return container_of(e, struct remote, ent);
- ret = xcalloc(1, sizeof(struct remote));
ret->prune = -1; /* unspecified */
ret->prune_tags = -1; /* unspecified */
ret->name = xstrndup(name, len);
ret->prune = -1; /* unspecified */
ret->prune_tags = -1; /* unspecified */
ret->name = xstrndup(name, len);
}
ALLOC_GROW(branches, branches_nr + 1, branches_alloc);
}
ALLOC_GROW(branches, branches_nr + 1, branches_alloc);
- ret = xcalloc(1, sizeof(struct branch));
branches[branches_nr++] = ret;
ret->name = xstrndup(name, len);
ret->refname = xstrfmt("refs/heads/%s", ret->name);
branches[branches_nr++] = ret;
ret->name = xstrndup(name, len);
ret->refname = xstrfmt("refs/heads/%s", ret->name);
}
ALLOC_GROW(r->rewrite, r->rewrite_nr + 1, r->rewrite_alloc);
}
ALLOC_GROW(r->rewrite, r->rewrite_nr + 1, r->rewrite_alloc);
- ret = xcalloc(1, sizeof(struct rewrite));
r->rewrite[r->rewrite_nr++] = ret;
ret->base = xstrndup(base, len);
ret->baselen = len;
r->rewrite[r->rewrite_nr++] = ret;
ret->base = xstrndup(base, len);
ret->baselen = len;
remote = remote_get(ret->remote_name);
remote = remote_get(ret->remote_name);
- ret->merge = xcalloc(ret->merge_nr, sizeof(*ret->merge));
+ CALLOC_ARRAY(ret->merge, ret->merge_nr);
for (i = 0; i < ret->merge_nr; i++) {
ret->merge[i] = xcalloc(1, sizeof(**ret->merge));
ret->merge[i]->src = xstrdup(ret->merge_name[i]);
for (i = 0; i < ret->merge_nr; i++) {
ret->merge[i] = xcalloc(1, sizeof(**ret->merge));
ret->merge[i]->src = xstrdup(ret->merge_name[i]);
repo_set_commondir(repo, o->commondir);
if (!repo->objects->odb) {
repo_set_commondir(repo, o->commondir);
if (!repo->objects->odb) {
- repo->objects->odb = xcalloc(1, sizeof(*repo->objects->odb));
+ CALLOC_ARRAY(repo->objects->odb, 1);
repo->objects->odb_tail = &repo->objects->odb->next;
}
expand_base_dir(&repo->objects->odb->path, o->object_dir,
repo->objects->odb_tail = &repo->objects->odb->next;
}
expand_base_dir(&repo->objects->odb->path, o->object_dir,
int repo_read_index(struct repository *repo)
{
if (!repo->index)
int repo_read_index(struct repository *repo)
{
if (!repo->index)
- repo->index = xcalloc(1, sizeof(*repo->index));
+ CALLOC_ARRAY(repo->index, 1);
/* Complete the double-reference */
if (!repo->index->repo)
/* Complete the double-reference */
if (!repo->index->repo)
return;
if (!istate->resolve_undo) {
return;
if (!istate->resolve_undo) {
- resolve_undo = xcalloc(1, sizeof(*resolve_undo));
+ CALLOC_ARRAY(resolve_undo, 1);
resolve_undo->strdup_strings = 1;
istate->resolve_undo = resolve_undo;
}
resolve_undo->strdup_strings = 1;
istate->resolve_undo = resolve_undo;
}
int i;
const unsigned rawsz = the_hash_algo->rawsz;
int i;
const unsigned rawsz = the_hash_algo->rawsz;
- resolve_undo = xcalloc(1, sizeof(*resolve_undo));
+ CALLOC_ARRAY(resolve_undo, 1);
resolve_undo->strdup_strings = 1;
while (size) {
resolve_undo->strdup_strings = 1;
while (size) {
entry = hashmap_get_entry(map, &key, ent, NULL);
if (!entry) {
entry = hashmap_get_entry(map, &key, ent, NULL);
if (!entry) {
- entry = xcalloc(1, sizeof(struct path_and_oids_entry));
+ CALLOC_ARRAY(entry, 1);
hashmap_entry_init(&entry->ent, hash);
entry->path = xstrdup(key.path);
oidset_init(&entry->trees, 16);
hashmap_entry_init(&entry->ent, hash);
entry->path = xstrdup(key.path);
oidset_init(&entry->trees, 16);
void add_ref_exclusion(struct string_list **ref_excludes_p, const char *exclude)
{
if (!*ref_excludes_p) {
void add_ref_exclusion(struct string_list **ref_excludes_p, const char *exclude)
{
if (!*ref_excludes_p) {
- *ref_excludes_p = xcalloc(1, sizeof(**ref_excludes_p));
+ CALLOC_ARRAY(*ref_excludes_p, 1);
(*ref_excludes_p)->strdup_strings = 1;
}
string_list_append(*ref_excludes_p, exclude);
(*ref_excludes_p)->strdup_strings = 1;
}
string_list_append(*ref_excludes_p, exclude);
st = lookup_decoration(&revs->merge_simplification, &commit->object);
if (!st) {
st = lookup_decoration(&revs->merge_simplification, &commit->object);
if (!st) {
- st = xcalloc(1, sizeof(*st));
add_decoration(&revs->merge_simplification, &commit->object, st);
}
return st;
add_decoration(&revs->merge_simplification, &commit->object, st);
}
return st;
pp->nr_processes = 0;
pp->output_owner = 0;
pp->shutdown = 0;
pp->nr_processes = 0;
pp->output_owner = 0;
pp->shutdown = 0;
- pp->children = xcalloc(n, sizeof(*pp->children));
- pp->pfd = xcalloc(n, sizeof(*pp->pfd));
+ CALLOC_ARRAY(pp->children, n);
+ CALLOC_ARRAY(pp->pfd, n);
strbuf_init(&pp->buffered_output, 0);
for (i = 0; i < n; i++) {
strbuf_init(&pp->buffered_output, 0);
for (i = 0; i < n; i++) {
}
if (new_report) {
if (!hint->report) {
}
if (new_report) {
if (!hint->report) {
- hint->report = xcalloc(1, sizeof(struct ref_push_report));
+ CALLOC_ARRAY(hint->report, 1);
report = hint->report;
} else {
report = hint->report;
while (report->next)
report = report->next;
report = hint->report;
} else {
report = hint->report;
while (report->next)
report = report->next;
- report->next = xcalloc(1, sizeof(struct ref_push_report));
+ CALLOC_ARRAY(report->next, 1);
report = report->next;
}
new_report = 0;
report = report->next;
}
new_report = 0;
int i, insert, nr = 0, alloc = 0;
struct todo_item *items = NULL, *base_items = NULL;
int i, insert, nr = 0, alloc = 0;
struct todo_item *items = NULL, *base_items = NULL;
- base_items = xcalloc(commands->nr, sizeof(struct todo_item));
+ CALLOC_ARRAY(base_items, commands->nr);
for (i = 0; i < commands->nr; i++) {
size_t command_len = strlen(commands->items[i].string);
for (i = 0; i < commands->nr; i++) {
size_t command_len = strlen(commands->items[i].string);
i = num_pack++;
ALLOC_GROW(info, num_pack, alloc);
i = num_pack++;
ALLOC_GROW(info, num_pack, alloc);
- info[i] = xcalloc(1, sizeof(struct pack_info));
+ CALLOC_ARRAY(info[i], 1);
info[i]->p = p;
info[i]->old_num = -1;
}
info[i]->p = p;
info[i]->old_num = -1;
}
struct split_index *init_split_index(struct index_state *istate)
{
if (!istate->split_index) {
struct split_index *init_split_index(struct index_state *istate)
{
if (!istate->split_index) {
- istate->split_index = xcalloc(1, sizeof(*istate->split_index));
+ CALLOC_ARRAY(istate->split_index, 1);
istate->split_index->refcount = 1;
}
return istate->split_index;
istate->split_index->refcount = 1;
}
return istate->split_index;
mem_pool_combine(istate->ce_mem_pool, istate->split_index->base->ce_mem_pool);
}
mem_pool_combine(istate->ce_mem_pool, istate->split_index->base->ce_mem_pool);
}
- si->base = xcalloc(1, sizeof(*si->base));
+ CALLOC_ARRAY(si->base, 1);
si->base->version = istate->version;
/* zero timestamp disables racy test in ce_write_index() */
si->base->timestamp = istate->timestamp;
si->base->version = istate->version;
/* zero timestamp disables racy test in ce_write_index() */
si->base->timestamp = istate->timestamp;
}
/* Item does not already exists, create it */
}
/* Item does not already exists, create it */
- item = xcalloc(sizeof(*item), 1);
duplicate_conf(&item->conf, &default_conf_info);
item->conf.name = xstrdup(name);
duplicate_conf(&item->conf, &default_conf_info);
item->conf.name = xstrdup(name);
die(_("'option' without a matching 'ok/error' directive"));
if (state->new_report) {
if (!state->hint->report) {
die(_("'option' without a matching 'ok/error' directive"));
if (state->new_report) {
if (!state->hint->report) {
- state->hint->report = xcalloc(1, sizeof(struct ref_push_report));
+ CALLOC_ARRAY(state->hint->report, 1);
state->report = state->hint->report;
} else {
state->report = state->hint->report;
while (state->report->next)
state->report = state->report->next;
state->report = state->hint->report;
} else {
state->report = state->hint->report;
while (state->report->next)
state->report = state->report->next;
- state->report->next = xcalloc(1, sizeof(struct ref_push_report));
+ CALLOC_ARRAY(state->report->next, 1);
state->report = state->report->next;
}
state->new_report = 0;
state->report = state->report->next;
}
state->new_report = 0;
BUG("taking over transport requires non-NULL "
"smart_options field.");
BUG("taking over transport requires non-NULL "
"smart_options field.");
- data = xcalloc(1, sizeof(*data));
data->options = *transport->smart_options;
data->conn = child;
data->fd[0] = data->conn->out;
data->options = *transport->smart_options;
data->conn = child;
data->fd[0] = data->conn->out;
strbuf_add_real_path(&worktree_path, get_git_common_dir());
strbuf_strip_suffix(&worktree_path, "/.git");
strbuf_add_real_path(&worktree_path, get_git_common_dir());
strbuf_strip_suffix(&worktree_path, "/.git");
- worktree = xcalloc(1, sizeof(*worktree));
+ CALLOC_ARRAY(worktree, 1);
worktree->path = strbuf_detach(&worktree_path, NULL);
/*
* NEEDSWORK: If this function is called from a secondary worktree and
worktree->path = strbuf_detach(&worktree_path, NULL);
/*
* NEEDSWORK: If this function is called from a secondary worktree and
strbuf_rtrim(&worktree_path);
strbuf_strip_suffix(&worktree_path, "/.git");
strbuf_rtrim(&worktree_path);
strbuf_strip_suffix(&worktree_path, "/.git");
- worktree = xcalloc(1, sizeof(*worktree));
+ CALLOC_ARRAY(worktree, 1);
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = xstrdup(id);
add_head_info(worktree);
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = xstrdup(id);
add_head_info(worktree);
it = string_list_insert(&s->change, p->two->path);
d = it->util;
if (!d) {
it = string_list_insert(&s->change, p->two->path);
d = it->util;
if (!d) {
- d = xcalloc(1, sizeof(*d));
it->util = d;
}
if (!d->worktree_status)
it->util = d;
}
if (!d->worktree_status)
it = string_list_insert(&s->change, p->two->path);
d = it->util;
if (!d) {
it = string_list_insert(&s->change, p->two->path);
d = it->util;
if (!d) {
- d = xcalloc(1, sizeof(*d));
it->util = d;
}
if (!d->index_status)
it->util = d;
}
if (!d->index_status)
it = string_list_insert(&s->change, ce->name);
d = it->util;
if (!d) {
it = string_list_insert(&s->change, ce->name);
d = it->util;
if (!d) {
- d = xcalloc(1, sizeof(*d));
it->util = d;
}
if (ce_stage(ce)) {
it->util = d;
}
if (ce_stage(ce)) {