зеркало из https://github.com/microsoft/git.git
string_list API users: use string_list_init_{no,}dup
Follow-up on the introduction of string_list_init_nodup() and
string_list_init_dup() in the series merged in bd4232fac3
(Merge
branch 'ab/struct-init', 2021-07-16) and convert code that implicitly
relied on xcalloc() being equivalent to the initializer to use
xmalloc() and string_list_init_{no,}dup() instead.
In the case of get_unmerged() in merge-recursive.c we used the
combination of xcalloc() and assigning "1" to "strdup_strings" to get
what we'd get via string_list_init_dup(), let's use that instead.
Adjacent code in cmd_format_patch() will be changed in a subsequent
commit, since we're changing that let's change the other in-tree
patterns that do the same. Let's also convert a "x == NULL" to "!x"
per our CodingGuidelines, as we need to change the "if" line anyway.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
4b59b2db97
Коммит
f260505142
|
@ -231,7 +231,8 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mailmap) {
|
if (mailmap) {
|
||||||
rev->mailmap = xcalloc(1, sizeof(struct string_list));
|
rev->mailmap = xmalloc(sizeof(struct string_list));
|
||||||
|
string_list_init_nodup(rev->mailmap);
|
||||||
read_mailmap(rev->mailmap);
|
read_mailmap(rev->mailmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2173,8 +2174,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
prepare_bases(&bases, base, list, nr);
|
prepare_bases(&bases, base, list, nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_reply_to || thread || cover_letter)
|
if (in_reply_to || thread || cover_letter) {
|
||||||
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
|
rev.ref_message_ids = xmalloc(sizeof(*rev.ref_message_ids));
|
||||||
|
string_list_init_nodup(rev.ref_message_ids);
|
||||||
|
}
|
||||||
if (in_reply_to) {
|
if (in_reply_to) {
|
||||||
const char *msgid = clean_message_id(in_reply_to);
|
const char *msgid = clean_message_id(in_reply_to);
|
||||||
string_list_append(rev.ref_message_ids, msgid);
|
string_list_append(rev.ref_message_ids, msgid);
|
||||||
|
|
|
@ -81,8 +81,10 @@ static void insert_one_record(struct shortlog *log,
|
||||||
format_subject(&subject, oneline, " ");
|
format_subject(&subject, oneline, " ");
|
||||||
buffer = strbuf_detach(&subject, NULL);
|
buffer = strbuf_detach(&subject, NULL);
|
||||||
|
|
||||||
if (item->util == NULL)
|
if (!item->util) {
|
||||||
item->util = xcalloc(1, sizeof(struct string_list));
|
item->util = xmalloc(sizeof(struct string_list));
|
||||||
|
string_list_init_nodup(item->util);
|
||||||
|
}
|
||||||
string_list_append(item->util, buffer);
|
string_list_append(item->util, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,10 +522,10 @@ static struct stage_data *insert_stage_data(struct repository *r,
|
||||||
*/
|
*/
|
||||||
static struct string_list *get_unmerged(struct index_state *istate)
|
static struct string_list *get_unmerged(struct index_state *istate)
|
||||||
{
|
{
|
||||||
struct string_list *unmerged = xcalloc(1, sizeof(struct string_list));
|
struct string_list *unmerged = xmalloc(sizeof(struct string_list));
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
unmerged->strdup_strings = 1;
|
string_list_init_dup(unmerged);
|
||||||
|
|
||||||
/* TODO: audit for interaction with sparse-index. */
|
/* TODO: audit for interaction with sparse-index. */
|
||||||
ensure_full_index(istate);
|
ensure_full_index(istate);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче