Merge branch 'ab/free-and-null'
A common pattern to free a piece of memory and assign NULL to the pointer that used to point at it has been replaced with a new FREE_AND_NULL() macro. * ab/free-and-null: *.[ch] refactoring: make use of the FREE_AND_NULL() macro coccinelle: make use of the "expression" FREE_AND_NULL() rule coccinelle: add a rule to make "expression" code use FREE_AND_NULL() coccinelle: make use of the "type" FREE_AND_NULL() rule coccinelle: add a rule to make "type" code use FREE_AND_NULL() git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
This commit is contained in:
commit
50f03c6676
6
alias.c
6
alias.c
@ -62,8 +62,7 @@ int split_cmdline(char *cmdline, const char ***argv)
|
|||||||
src++;
|
src++;
|
||||||
c = cmdline[src];
|
c = cmdline[src];
|
||||||
if (!c) {
|
if (!c) {
|
||||||
free(*argv);
|
FREE_AND_NULL(*argv);
|
||||||
*argv = NULL;
|
|
||||||
return -SPLIT_CMDLINE_BAD_ENDING;
|
return -SPLIT_CMDLINE_BAD_ENDING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,8 +74,7 @@ int split_cmdline(char *cmdline, const char ***argv)
|
|||||||
cmdline[dst] = 0;
|
cmdline[dst] = 0;
|
||||||
|
|
||||||
if (quoted) {
|
if (quoted) {
|
||||||
free(*argv);
|
FREE_AND_NULL(*argv);
|
||||||
*argv = NULL;
|
|
||||||
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
|
return -SPLIT_CMDLINE_UNCLOSED_QUOTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
apply.c
3
apply.c
@ -3695,8 +3695,7 @@ static int check_preimage(struct apply_state *state,
|
|||||||
is_new:
|
is_new:
|
||||||
patch->is_new = 1;
|
patch->is_new = 1;
|
||||||
patch->is_delete = 0;
|
patch->is_delete = 0;
|
||||||
free(patch->old_name);
|
FREE_AND_NULL(patch->old_name);
|
||||||
patch->old_name = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
attr.c
6
attr.c
@ -639,13 +639,11 @@ void attr_check_reset(struct attr_check *check)
|
|||||||
|
|
||||||
void attr_check_clear(struct attr_check *check)
|
void attr_check_clear(struct attr_check *check)
|
||||||
{
|
{
|
||||||
free(check->items);
|
FREE_AND_NULL(check->items);
|
||||||
check->items = NULL;
|
|
||||||
check->alloc = 0;
|
check->alloc = 0;
|
||||||
check->nr = 0;
|
check->nr = 0;
|
||||||
|
|
||||||
free(check->all_attrs);
|
FREE_AND_NULL(check->all_attrs);
|
||||||
check->all_attrs = NULL;
|
|
||||||
check->all_attrs_nr = 0;
|
check->all_attrs_nr = 0;
|
||||||
|
|
||||||
drop_attr_stack(&check->stack);
|
drop_attr_stack(&check->stack);
|
||||||
|
3
blame.c
3
blame.c
@ -314,8 +314,7 @@ static void fill_origin_blob(struct diff_options *opt,
|
|||||||
static void drop_origin_blob(struct blame_origin *o)
|
static void drop_origin_blob(struct blame_origin *o)
|
||||||
{
|
{
|
||||||
if (o->file.ptr) {
|
if (o->file.ptr) {
|
||||||
free(o->file.ptr);
|
FREE_AND_NULL(o->file.ptr);
|
||||||
o->file.ptr = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
branch.c
3
branch.c
@ -25,8 +25,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
|
|||||||
} else {
|
} else {
|
||||||
free(tracking->spec.src);
|
free(tracking->spec.src);
|
||||||
if (tracking->src) {
|
if (tracking->src) {
|
||||||
free(tracking->src);
|
FREE_AND_NULL(tracking->src);
|
||||||
tracking->src = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tracking->spec.src = NULL;
|
tracking->spec.src = NULL;
|
||||||
|
18
builtin/am.c
18
builtin/am.c
@ -484,8 +484,7 @@ static int run_applypatch_msg_hook(struct am_state *state)
|
|||||||
ret = run_hook_le(NULL, "applypatch-msg", am_path(state, "final-commit"), NULL);
|
ret = run_hook_le(NULL, "applypatch-msg", am_path(state, "final-commit"), NULL);
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
free(state->msg);
|
FREE_AND_NULL(state->msg);
|
||||||
state->msg = NULL;
|
|
||||||
if (read_commit_msg(state) < 0)
|
if (read_commit_msg(state) < 0)
|
||||||
die(_("'%s' was deleted by the applypatch-msg hook"),
|
die(_("'%s' was deleted by the applypatch-msg hook"),
|
||||||
am_path(state, "final-commit"));
|
am_path(state, "final-commit"));
|
||||||
@ -1074,17 +1073,10 @@ static void am_next(struct am_state *state)
|
|||||||
{
|
{
|
||||||
struct object_id head;
|
struct object_id head;
|
||||||
|
|
||||||
free(state->author_name);
|
FREE_AND_NULL(state->author_name);
|
||||||
state->author_name = NULL;
|
FREE_AND_NULL(state->author_email);
|
||||||
|
FREE_AND_NULL(state->author_date);
|
||||||
free(state->author_email);
|
FREE_AND_NULL(state->msg);
|
||||||
state->author_email = NULL;
|
|
||||||
|
|
||||||
free(state->author_date);
|
|
||||||
state->author_date = NULL;
|
|
||||||
|
|
||||||
free(state->msg);
|
|
||||||
state->msg = NULL;
|
|
||||||
state->msg_len = 0;
|
state->msg_len = 0;
|
||||||
|
|
||||||
unlink(am_path(state, "author-script"));
|
unlink(am_path(state, "author-script"));
|
||||||
|
@ -838,8 +838,7 @@ static void interactive_main_loop(void)
|
|||||||
int ret;
|
int ret;
|
||||||
ret = menus[*chosen].fn();
|
ret = menus[*chosen].fn();
|
||||||
if (ret != MENU_RETURN_NO_LOOP) {
|
if (ret != MENU_RETURN_NO_LOOP) {
|
||||||
free(chosen);
|
FREE_AND_NULL(chosen);
|
||||||
chosen = NULL;
|
|
||||||
if (!del_list.nr) {
|
if (!del_list.nr) {
|
||||||
clean_print_color(CLEAN_COLOR_ERROR);
|
clean_print_color(CLEAN_COLOR_ERROR);
|
||||||
printf_ln(_("No more files to clean, exiting."));
|
printf_ln(_("No more files to clean, exiting."));
|
||||||
@ -852,8 +851,7 @@ static void interactive_main_loop(void)
|
|||||||
quit_cmd();
|
quit_cmd();
|
||||||
}
|
}
|
||||||
|
|
||||||
free(chosen);
|
FREE_AND_NULL(chosen);
|
||||||
chosen = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,8 +215,7 @@ static int get_value(const char *key_, const char *regex_)
|
|||||||
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
|
key_regexp = (regex_t*)xmalloc(sizeof(regex_t));
|
||||||
if (regcomp(key_regexp, key, REG_EXTENDED)) {
|
if (regcomp(key_regexp, key, REG_EXTENDED)) {
|
||||||
error("invalid key pattern: %s", key_);
|
error("invalid key pattern: %s", key_);
|
||||||
free(key_regexp);
|
FREE_AND_NULL(key_regexp);
|
||||||
key_regexp = NULL;
|
|
||||||
ret = CONFIG_INVALID_PATTERN;
|
ret = CONFIG_INVALID_PATTERN;
|
||||||
goto free_strings;
|
goto free_strings;
|
||||||
}
|
}
|
||||||
@ -236,8 +235,7 @@ static int get_value(const char *key_, const char *regex_)
|
|||||||
regexp = (regex_t*)xmalloc(sizeof(regex_t));
|
regexp = (regex_t*)xmalloc(sizeof(regex_t));
|
||||||
if (regcomp(regexp, regex_, REG_EXTENDED)) {
|
if (regcomp(regexp, regex_, REG_EXTENDED)) {
|
||||||
error("invalid pattern: %s", regex_);
|
error("invalid pattern: %s", regex_);
|
||||||
free(regexp);
|
FREE_AND_NULL(regexp);
|
||||||
regexp = NULL;
|
|
||||||
ret = CONFIG_INVALID_PATTERN;
|
ret = CONFIG_INVALID_PATTERN;
|
||||||
goto free_strings;
|
goto free_strings;
|
||||||
}
|
}
|
||||||
|
@ -389,8 +389,7 @@ static struct base_data *alloc_base_data(void)
|
|||||||
static void free_base_data(struct base_data *c)
|
static void free_base_data(struct base_data *c)
|
||||||
{
|
{
|
||||||
if (c->data) {
|
if (c->data) {
|
||||||
free(c->data);
|
FREE_AND_NULL(c->data);
|
||||||
c->data = NULL;
|
|
||||||
get_thread_data()->base_cache_used -= c->size;
|
get_thread_data()->base_cache_used -= c->size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,8 +605,7 @@ static void *unpack_data(struct object_entry *obj,
|
|||||||
git_inflate_end(&stream);
|
git_inflate_end(&stream);
|
||||||
free(inbuf);
|
free(inbuf);
|
||||||
if (consume) {
|
if (consume) {
|
||||||
free(data);
|
FREE_AND_NULL(data);
|
||||||
data = NULL;
|
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -265,8 +265,7 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent
|
|||||||
* make sure no cached delta data remains from a
|
* make sure no cached delta data remains from a
|
||||||
* previous attempt before a pack split occurred.
|
* previous attempt before a pack split occurred.
|
||||||
*/
|
*/
|
||||||
free(entry->delta_data);
|
FREE_AND_NULL(entry->delta_data);
|
||||||
entry->delta_data = NULL;
|
|
||||||
entry->z_delta_size = 0;
|
entry->z_delta_size = 0;
|
||||||
} else if (entry->delta_data) {
|
} else if (entry->delta_data) {
|
||||||
size = entry->delta_size;
|
size = entry->delta_size;
|
||||||
@ -1376,12 +1375,10 @@ static void cleanup_preferred_base(void)
|
|||||||
if (!pbase_tree_cache[i])
|
if (!pbase_tree_cache[i])
|
||||||
continue;
|
continue;
|
||||||
free(pbase_tree_cache[i]->tree_data);
|
free(pbase_tree_cache[i]->tree_data);
|
||||||
free(pbase_tree_cache[i]);
|
FREE_AND_NULL(pbase_tree_cache[i]);
|
||||||
pbase_tree_cache[i] = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(done_pbase_paths);
|
FREE_AND_NULL(done_pbase_paths);
|
||||||
done_pbase_paths = NULL;
|
|
||||||
done_pbase_paths_num = done_pbase_paths_alloc = 0;
|
done_pbase_paths_num = done_pbase_paths_alloc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1971,8 +1968,7 @@ static unsigned long free_unpacked(struct unpacked *n)
|
|||||||
n->index = NULL;
|
n->index = NULL;
|
||||||
if (n->data) {
|
if (n->data) {
|
||||||
freed_mem += n->entry->size;
|
freed_mem += n->entry->size;
|
||||||
free(n->data);
|
FREE_AND_NULL(n->data);
|
||||||
n->data = NULL;
|
|
||||||
}
|
}
|
||||||
n->entry = NULL;
|
n->entry = NULL;
|
||||||
n->depth = 0;
|
n->depth = 0;
|
||||||
|
@ -113,8 +113,7 @@ static void *get_data(unsigned long size)
|
|||||||
break;
|
break;
|
||||||
if (ret != Z_OK) {
|
if (ret != Z_OK) {
|
||||||
error("inflate returned %d", ret);
|
error("inflate returned %d", ret);
|
||||||
free(buf);
|
FREE_AND_NULL(buf);
|
||||||
buf = NULL;
|
|
||||||
if (!recover)
|
if (!recover)
|
||||||
exit(1);
|
exit(1);
|
||||||
has_errors = 1;
|
has_errors = 1;
|
||||||
|
@ -300,10 +300,8 @@ static int add_worktree(const char *path, const char *refname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_junk = 0;
|
is_junk = 0;
|
||||||
free(junk_work_tree);
|
FREE_AND_NULL(junk_work_tree);
|
||||||
free(junk_git_dir);
|
FREE_AND_NULL(junk_git_dir);
|
||||||
junk_work_tree = NULL;
|
|
||||||
junk_git_dir = NULL;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (ret || !opts->keep_locked) {
|
if (ret || !opts->keep_locked) {
|
||||||
|
@ -82,8 +82,7 @@ static MAYBE_UNUSED void clear_ ##slabname(struct slabname *s) \
|
|||||||
for (i = 0; i < s->slab_count; i++) \
|
for (i = 0; i < s->slab_count; i++) \
|
||||||
free(s->slab[i]); \
|
free(s->slab[i]); \
|
||||||
s->slab_count = 0; \
|
s->slab_count = 0; \
|
||||||
free(s->slab); \
|
FREE_AND_NULL(s->slab); \
|
||||||
s->slab = NULL; \
|
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
|
static MAYBE_UNUSED elemtype *slabname## _at_peek(struct slabname *s, \
|
||||||
|
3
commit.c
3
commit.c
@ -287,8 +287,7 @@ void free_commit_buffer(struct commit *commit)
|
|||||||
{
|
{
|
||||||
struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
|
struct commit_buffer *v = buffer_slab_peek(&buffer_slab, commit);
|
||||||
if (v) {
|
if (v) {
|
||||||
free(v->buffer);
|
FREE_AND_NULL(v->buffer);
|
||||||
v->buffer = NULL;
|
|
||||||
v->size = 0;
|
v->size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
config.c
3
config.c
@ -394,8 +394,7 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
|
|||||||
|
|
||||||
out_free_ret_1:
|
out_free_ret_1:
|
||||||
if (store_key) {
|
if (store_key) {
|
||||||
free(*store_key);
|
FREE_AND_NULL(*store_key);
|
||||||
*store_key = NULL;
|
|
||||||
}
|
}
|
||||||
return -CONFIG_INVALID_KEY;
|
return -CONFIG_INVALID_KEY;
|
||||||
}
|
}
|
||||||
|
@ -9,3 +9,18 @@ expression E;
|
|||||||
@@
|
@@
|
||||||
- if (!E)
|
- if (!E)
|
||||||
free(E);
|
free(E);
|
||||||
|
|
||||||
|
@@
|
||||||
|
type T;
|
||||||
|
T *ptr;
|
||||||
|
@@
|
||||||
|
- free(ptr);
|
||||||
|
- ptr = NULL;
|
||||||
|
+ FREE_AND_NULL(ptr);
|
||||||
|
|
||||||
|
@@
|
||||||
|
expression E;
|
||||||
|
@@
|
||||||
|
- free(E);
|
||||||
|
- E = NULL;
|
||||||
|
+ FREE_AND_NULL(E);
|
||||||
|
@ -94,8 +94,7 @@ static void credential_apply_config(struct credential *c)
|
|||||||
c->configured = 1;
|
c->configured = 1;
|
||||||
|
|
||||||
if (!c->use_http_path && proto_is_http(c->protocol)) {
|
if (!c->use_http_path && proto_is_http(c->protocol)) {
|
||||||
free(c->path);
|
FREE_AND_NULL(c->path);
|
||||||
c->path = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,10 +314,8 @@ void credential_reject(struct credential *c)
|
|||||||
for (i = 0; i < c->helpers.nr; i++)
|
for (i = 0; i < c->helpers.nr; i++)
|
||||||
credential_do(c, c->helpers.items[i].string, "erase");
|
credential_do(c, c->helpers.items[i].string, "erase");
|
||||||
|
|
||||||
free(c->username);
|
FREE_AND_NULL(c->username);
|
||||||
c->username = NULL;
|
FREE_AND_NULL(c->password);
|
||||||
free(c->password);
|
|
||||||
c->password = NULL;
|
|
||||||
c->approved = 0;
|
c->approved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,8 +179,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
|
|||||||
free(dpath);
|
free(dpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
free(dpath);
|
FREE_AND_NULL(dpath);
|
||||||
dpath = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show the diff for the 'ce' if we found the one
|
* Show the diff for the 'ce' if we found the one
|
||||||
|
6
diff.c
6
diff.c
@ -1219,8 +1219,7 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
|
|||||||
regfree(ecbdata->diff_words->word_regex);
|
regfree(ecbdata->diff_words->word_regex);
|
||||||
free(ecbdata->diff_words->word_regex);
|
free(ecbdata->diff_words->word_regex);
|
||||||
}
|
}
|
||||||
free(ecbdata->diff_words);
|
FREE_AND_NULL(ecbdata->diff_words);
|
||||||
ecbdata->diff_words = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2952,8 +2951,7 @@ void diff_free_filespec_blob(struct diff_filespec *s)
|
|||||||
void diff_free_filespec_data(struct diff_filespec *s)
|
void diff_free_filespec_data(struct diff_filespec *s)
|
||||||
{
|
{
|
||||||
diff_free_filespec_blob(s);
|
diff_free_filespec_blob(s);
|
||||||
free(s->cnt_data);
|
FREE_AND_NULL(s->cnt_data);
|
||||||
s->cnt_data = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
|
static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
|
||||||
|
@ -667,11 +667,9 @@ void diffcore_rename(struct diff_options *options)
|
|||||||
for (i = 0; i < rename_dst_nr; i++)
|
for (i = 0; i < rename_dst_nr; i++)
|
||||||
free_filespec(rename_dst[i].two);
|
free_filespec(rename_dst[i].two);
|
||||||
|
|
||||||
free(rename_dst);
|
FREE_AND_NULL(rename_dst);
|
||||||
rename_dst = NULL;
|
|
||||||
rename_dst_nr = rename_dst_alloc = 0;
|
rename_dst_nr = rename_dst_alloc = 0;
|
||||||
free(rename_src);
|
FREE_AND_NULL(rename_src);
|
||||||
rename_src = NULL;
|
|
||||||
rename_src_nr = rename_src_alloc = 0;
|
rename_src_nr = rename_src_alloc = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
9
dir.c
9
dir.c
@ -2127,8 +2127,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
|
|||||||
for (i = j = 0; j < dir->nr; j++) {
|
for (i = j = 0; j < dir->nr; j++) {
|
||||||
if (i &&
|
if (i &&
|
||||||
check_dir_entry_contains(dir->entries[i - 1], dir->entries[j])) {
|
check_dir_entry_contains(dir->entries[i - 1], dir->entries[j])) {
|
||||||
free(dir->entries[j]);
|
FREE_AND_NULL(dir->entries[j]);
|
||||||
dir->entries[j] = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
dir->entries[i++] = dir->entries[j];
|
dir->entries[i++] = dir->entries[j];
|
||||||
}
|
}
|
||||||
@ -2154,8 +2153,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
|
|||||||
dir->untracked->dir_invalidated))
|
dir->untracked->dir_invalidated))
|
||||||
istate->cache_changed |= UNTRACKED_CHANGED;
|
istate->cache_changed |= UNTRACKED_CHANGED;
|
||||||
if (dir->untracked != istate->untracked) {
|
if (dir->untracked != istate->untracked) {
|
||||||
free(dir->untracked);
|
FREE_AND_NULL(dir->untracked);
|
||||||
dir->untracked = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dir->nr;
|
return dir->nr;
|
||||||
@ -2498,8 +2496,7 @@ void write_untracked_extension(struct strbuf *out, struct untracked_cache *untra
|
|||||||
strbuf_addbuf(out, &untracked->ident);
|
strbuf_addbuf(out, &untracked->ident);
|
||||||
|
|
||||||
strbuf_add(out, ouc, ouc_size(len));
|
strbuf_add(out, ouc, ouc_size(len));
|
||||||
free(ouc);
|
FREE_AND_NULL(ouc);
|
||||||
ouc = NULL;
|
|
||||||
|
|
||||||
if (!untracked->root) {
|
if (!untracked->root) {
|
||||||
varint_len = encode_varint(0, varbuf);
|
varint_len = encode_varint(0, varbuf);
|
||||||
|
@ -1064,8 +1064,7 @@ discard_pack:
|
|||||||
close(pack_data->pack_fd);
|
close(pack_data->pack_fd);
|
||||||
unlink_or_warn(pack_data->pack_name);
|
unlink_or_warn(pack_data->pack_name);
|
||||||
}
|
}
|
||||||
free(pack_data);
|
FREE_AND_NULL(pack_data);
|
||||||
pack_data = NULL;
|
|
||||||
running = 0;
|
running = 0;
|
||||||
|
|
||||||
/* We can't carry a delta across packfiles. */
|
/* We can't carry a delta across packfiles. */
|
||||||
@ -1150,8 +1149,7 @@ static int store_object(
|
|||||||
|
|
||||||
/* We cannot carry a delta into the new pack. */
|
/* We cannot carry a delta into the new pack. */
|
||||||
if (delta) {
|
if (delta) {
|
||||||
free(delta);
|
FREE_AND_NULL(delta);
|
||||||
delta = NULL;
|
|
||||||
|
|
||||||
git_deflate_init(&s, pack_compression_level);
|
git_deflate_init(&s, pack_compression_level);
|
||||||
s.next_in = (void *)dat->buf;
|
s.next_in = (void *)dat->buf;
|
||||||
|
@ -808,6 +808,12 @@ extern char *xgetcwd(void);
|
|||||||
extern FILE *fopen_for_writing(const char *path);
|
extern FILE *fopen_for_writing(const char *path);
|
||||||
extern FILE *fopen_or_warn(const char *path, const char *mode);
|
extern FILE *fopen_or_warn(const char *path, const char *mode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FREE_AND_NULL(ptr) is like free(ptr) followed by ptr = NULL. Note
|
||||||
|
* that ptr is used twice, so don't pass e.g. ptr++.
|
||||||
|
*/
|
||||||
|
#define FREE_AND_NULL(p) do { free(p); (p) = NULL; } while (0)
|
||||||
|
|
||||||
#define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
|
#define ALLOC_ARRAY(x, alloc) (x) = xmalloc(st_mult(sizeof(*(x)), (alloc)))
|
||||||
#define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))
|
#define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), st_mult(sizeof(*(x)), (alloc)))
|
||||||
|
|
||||||
|
@ -14,16 +14,11 @@ static const char *gpg_program = "gpg";
|
|||||||
|
|
||||||
void signature_check_clear(struct signature_check *sigc)
|
void signature_check_clear(struct signature_check *sigc)
|
||||||
{
|
{
|
||||||
free(sigc->payload);
|
FREE_AND_NULL(sigc->payload);
|
||||||
free(sigc->gpg_output);
|
FREE_AND_NULL(sigc->gpg_output);
|
||||||
free(sigc->gpg_status);
|
FREE_AND_NULL(sigc->gpg_status);
|
||||||
free(sigc->signer);
|
FREE_AND_NULL(sigc->signer);
|
||||||
free(sigc->key);
|
FREE_AND_NULL(sigc->key);
|
||||||
sigc->payload = NULL;
|
|
||||||
sigc->gpg_output = NULL;
|
|
||||||
sigc->gpg_status = NULL;
|
|
||||||
sigc->signer = NULL;
|
|
||||||
sigc->key = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
12
grep.c
12
grep.c
@ -1940,12 +1940,9 @@ void grep_source_init(struct grep_source *gs, enum grep_source_type type,
|
|||||||
|
|
||||||
void grep_source_clear(struct grep_source *gs)
|
void grep_source_clear(struct grep_source *gs)
|
||||||
{
|
{
|
||||||
free(gs->name);
|
FREE_AND_NULL(gs->name);
|
||||||
gs->name = NULL;
|
FREE_AND_NULL(gs->path);
|
||||||
free(gs->path);
|
FREE_AND_NULL(gs->identifier);
|
||||||
gs->path = NULL;
|
|
||||||
free(gs->identifier);
|
|
||||||
gs->identifier = NULL;
|
|
||||||
grep_source_clear_data(gs);
|
grep_source_clear_data(gs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1955,8 +1952,7 @@ void grep_source_clear_data(struct grep_source *gs)
|
|||||||
case GREP_SOURCE_FILE:
|
case GREP_SOURCE_FILE:
|
||||||
case GREP_SOURCE_OID:
|
case GREP_SOURCE_OID:
|
||||||
case GREP_SOURCE_SUBMODULE:
|
case GREP_SOURCE_SUBMODULE:
|
||||||
free(gs->buf);
|
FREE_AND_NULL(gs->buf);
|
||||||
gs->buf = NULL;
|
|
||||||
gs->size = 0;
|
gs->size = 0;
|
||||||
break;
|
break;
|
||||||
case GREP_SOURCE_BUF:
|
case GREP_SOURCE_BUF:
|
||||||
|
3
help.c
3
help.c
@ -269,9 +269,8 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
|
|||||||
|
|
||||||
for (i = 0; i < old->cnt; i++)
|
for (i = 0; i < old->cnt; i++)
|
||||||
cmds->names[cmds->cnt++] = old->names[i];
|
cmds->names[cmds->cnt++] = old->names[i];
|
||||||
free(old->names);
|
FREE_AND_NULL(old->names);
|
||||||
old->cnt = 0;
|
old->cnt = 0;
|
||||||
old->names = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An empirically derived magic number */
|
/* An empirically derived magic number */
|
||||||
|
24
http-push.c
24
http-push.c
@ -291,8 +291,7 @@ static void start_mkcol(struct transfer_request *request)
|
|||||||
request->state = RUN_MKCOL;
|
request->state = RUN_MKCOL;
|
||||||
} else {
|
} else {
|
||||||
request->state = ABORTED;
|
request->state = ABORTED;
|
||||||
free(request->url);
|
FREE_AND_NULL(request->url);
|
||||||
request->url = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -409,8 +408,7 @@ static void start_put(struct transfer_request *request)
|
|||||||
request->state = RUN_PUT;
|
request->state = RUN_PUT;
|
||||||
} else {
|
} else {
|
||||||
request->state = ABORTED;
|
request->state = ABORTED;
|
||||||
free(request->url);
|
FREE_AND_NULL(request->url);
|
||||||
request->url = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,8 +430,7 @@ static void start_move(struct transfer_request *request)
|
|||||||
request->state = RUN_MOVE;
|
request->state = RUN_MOVE;
|
||||||
} else {
|
} else {
|
||||||
request->state = ABORTED;
|
request->state = ABORTED;
|
||||||
free(request->url);
|
FREE_AND_NULL(request->url);
|
||||||
request->url = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -526,8 +523,7 @@ static void finish_request(struct transfer_request *request)
|
|||||||
|
|
||||||
/* URL is reused for MOVE after PUT */
|
/* URL is reused for MOVE after PUT */
|
||||||
if (request->state != RUN_PUT) {
|
if (request->state != RUN_PUT) {
|
||||||
free(request->url);
|
FREE_AND_NULL(request->url);
|
||||||
request->url = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request->state == RUN_MKCOL) {
|
if (request->state == RUN_MKCOL) {
|
||||||
@ -803,8 +799,7 @@ xml_start_tag(void *userData, const char *name, const char **atts)
|
|||||||
}
|
}
|
||||||
xsnprintf(ctx->name + old_namelen, ctx->len - old_namelen, ".%s", c);
|
xsnprintf(ctx->name + old_namelen, ctx->len - old_namelen, ".%s", c);
|
||||||
|
|
||||||
free(ctx->cdata);
|
FREE_AND_NULL(ctx->cdata);
|
||||||
ctx->cdata = NULL;
|
|
||||||
|
|
||||||
ctx->userFunc(ctx, 0);
|
ctx->userFunc(ctx, 0);
|
||||||
}
|
}
|
||||||
@ -932,8 +927,7 @@ static struct remote_lock *lock_remote(const char *path, long timeout)
|
|||||||
free(lock->token);
|
free(lock->token);
|
||||||
free(lock->owner);
|
free(lock->owner);
|
||||||
free(url);
|
free(url);
|
||||||
free(lock);
|
FREE_AND_NULL(lock);
|
||||||
lock = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
lock->url = url;
|
lock->url = url;
|
||||||
lock->start_time = time(NULL);
|
lock->start_time = time(NULL);
|
||||||
@ -1105,8 +1099,7 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
|
|||||||
ls->dentry_flags |= IS_DIR;
|
ls->dentry_flags |= IS_DIR;
|
||||||
}
|
}
|
||||||
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
} else if (!strcmp(ctx->name, DAV_PROPFIND_RESP)) {
|
||||||
free(ls->dentry_name);
|
FREE_AND_NULL(ls->dentry_name);
|
||||||
ls->dentry_name = NULL;
|
|
||||||
ls->dentry_flags = 0;
|
ls->dentry_flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1547,8 +1540,7 @@ static void fetch_symref(const char *path, char **symref, struct object_id *oid)
|
|||||||
curl_errorstr);
|
curl_errorstr);
|
||||||
free(url);
|
free(url);
|
||||||
|
|
||||||
free(*symref);
|
FREE_AND_NULL(*symref);
|
||||||
*symref = NULL;
|
|
||||||
oidclr(oid);
|
oidclr(oid);
|
||||||
|
|
||||||
if (buffer.len == 0)
|
if (buffer.len == 0)
|
||||||
|
15
http.c
15
http.c
@ -1027,8 +1027,7 @@ void http_cleanup(void)
|
|||||||
|
|
||||||
if (proxy_auth.password) {
|
if (proxy_auth.password) {
|
||||||
memset(proxy_auth.password, 0, strlen(proxy_auth.password));
|
memset(proxy_auth.password, 0, strlen(proxy_auth.password));
|
||||||
free(proxy_auth.password);
|
FREE_AND_NULL(proxy_auth.password);
|
||||||
proxy_auth.password = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void *)curl_proxyuserpwd);
|
free((void *)curl_proxyuserpwd);
|
||||||
@ -1039,13 +1038,11 @@ void http_cleanup(void)
|
|||||||
|
|
||||||
if (cert_auth.password != NULL) {
|
if (cert_auth.password != NULL) {
|
||||||
memset(cert_auth.password, 0, strlen(cert_auth.password));
|
memset(cert_auth.password, 0, strlen(cert_auth.password));
|
||||||
free(cert_auth.password);
|
FREE_AND_NULL(cert_auth.password);
|
||||||
cert_auth.password = NULL;
|
|
||||||
}
|
}
|
||||||
ssl_cert_password_required = 0;
|
ssl_cert_password_required = 0;
|
||||||
|
|
||||||
free(cached_accept_language);
|
FREE_AND_NULL(cached_accept_language);
|
||||||
cached_accept_language = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct active_request_slot *get_active_slot(void)
|
struct active_request_slot *get_active_slot(void)
|
||||||
@ -1897,8 +1894,7 @@ static char *fetch_pack_index(unsigned char *sha1, const char *base_url)
|
|||||||
|
|
||||||
if (http_get_file(url, tmp, NULL) != HTTP_OK) {
|
if (http_get_file(url, tmp, NULL) != HTTP_OK) {
|
||||||
error("Unable to get pack index %s", url);
|
error("Unable to get pack index %s", url);
|
||||||
free(tmp);
|
FREE_AND_NULL(tmp);
|
||||||
tmp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(url);
|
free(url);
|
||||||
@ -2329,8 +2325,7 @@ void release_http_object_request(struct http_object_request *freq)
|
|||||||
freq->localfile = -1;
|
freq->localfile = -1;
|
||||||
}
|
}
|
||||||
if (freq->url != NULL) {
|
if (freq->url != NULL) {
|
||||||
free(freq->url);
|
FREE_AND_NULL(freq->url);
|
||||||
freq->url = NULL;
|
|
||||||
}
|
}
|
||||||
if (freq->slot != NULL) {
|
if (freq->slot != NULL) {
|
||||||
freq->slot->callback_func = NULL;
|
freq->slot->callback_func = NULL;
|
||||||
|
@ -777,8 +777,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
|
|||||||
offsetof(struct imap_cmd, next));
|
offsetof(struct imap_cmd, next));
|
||||||
if (cmdp->cb.data) {
|
if (cmdp->cb.data) {
|
||||||
n = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);
|
n = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);
|
||||||
free(cmdp->cb.data);
|
FREE_AND_NULL(cmdp->cb.data);
|
||||||
cmdp->cb.data = NULL;
|
|
||||||
if (n != (int)cmdp->cb.dlen)
|
if (n != (int)cmdp->cb.dlen)
|
||||||
return RESP_BAD;
|
return RESP_BAD;
|
||||||
} else if (cmdp->cb.cont) {
|
} else if (cmdp->cb.cont) {
|
||||||
|
@ -34,9 +34,8 @@ void range_set_init(struct range_set *rs, size_t prealloc)
|
|||||||
|
|
||||||
void range_set_release(struct range_set *rs)
|
void range_set_release(struct range_set *rs)
|
||||||
{
|
{
|
||||||
free(rs->ranges);
|
FREE_AND_NULL(rs->ranges);
|
||||||
rs->alloc = rs->nr = 0;
|
rs->alloc = rs->nr = 0;
|
||||||
rs->ranges = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dst must be uninitialized! */
|
/* dst must be uninitialized! */
|
||||||
@ -610,8 +609,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
|
|||||||
line_log_data_insert(&ranges, full_name, begin, end);
|
line_log_data_insert(&ranges, full_name, begin, end);
|
||||||
|
|
||||||
free_filespec(spec);
|
free_filespec(spec);
|
||||||
free(ends);
|
FREE_AND_NULL(ends);
|
||||||
ends = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (p = ranges; p; p = p->next)
|
for (p = ranges; p; p = p->next)
|
||||||
|
@ -210,8 +210,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
|
|||||||
result->size = st.st_size;
|
result->size = st.st_size;
|
||||||
result->ptr = xmallocz(result->size);
|
result->ptr = xmallocz(result->size);
|
||||||
if (read_in_full(fd, result->ptr, result->size) != result->size) {
|
if (read_in_full(fd, result->ptr, result->size) != result->size) {
|
||||||
free(result->ptr);
|
FREE_AND_NULL(result->ptr);
|
||||||
result->ptr = NULL;
|
|
||||||
result->size = 0;
|
result->size = 0;
|
||||||
}
|
}
|
||||||
close_bad:
|
close_bad:
|
||||||
|
@ -920,8 +920,7 @@ again:
|
|||||||
/* we hit an end boundary */
|
/* we hit an end boundary */
|
||||||
/* pop the current boundary off the stack */
|
/* pop the current boundary off the stack */
|
||||||
strbuf_release(*(mi->content_top));
|
strbuf_release(*(mi->content_top));
|
||||||
free(*(mi->content_top));
|
FREE_AND_NULL(*(mi->content_top));
|
||||||
*(mi->content_top) = NULL;
|
|
||||||
|
|
||||||
/* technically won't happen as is_multipart_boundary()
|
/* technically won't happen as is_multipart_boundary()
|
||||||
will fail first. But just in case..
|
will fail first. But just in case..
|
||||||
|
3
object.c
3
object.c
@ -377,8 +377,7 @@ void object_array_clear(struct object_array *array)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < array->nr; i++)
|
for (i = 0; i < array->nr; i++)
|
||||||
object_array_release_entry(&array->objects[i]);
|
object_array_release_entry(&array->objects[i]);
|
||||||
free(array->objects);
|
FREE_AND_NULL(array->objects);
|
||||||
array->objects = NULL;
|
|
||||||
array->nr = array->alloc = 0;
|
array->nr = array->alloc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,7 +663,6 @@ void clear_pathspec(struct pathspec *pathspec)
|
|||||||
attr_check_free(pathspec->items[i].attr_check);
|
attr_check_free(pathspec->items[i].attr_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(pathspec->items);
|
FREE_AND_NULL(pathspec->items);
|
||||||
pathspec->items = NULL;
|
|
||||||
pathspec->nr = 0;
|
pathspec->nr = 0;
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,9 @@ void prio_queue_reverse(struct prio_queue *queue)
|
|||||||
|
|
||||||
void clear_prio_queue(struct prio_queue *queue)
|
void clear_prio_queue(struct prio_queue *queue)
|
||||||
{
|
{
|
||||||
free(queue->array);
|
FREE_AND_NULL(queue->array);
|
||||||
queue->nr = 0;
|
queue->nr = 0;
|
||||||
queue->alloc = 0;
|
queue->alloc = 0;
|
||||||
queue->array = NULL;
|
|
||||||
queue->insertion_ctr = 0;
|
queue->insertion_ctr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1895,8 +1895,7 @@ int discard_index(struct index_state *istate)
|
|||||||
free_name_hash(istate);
|
free_name_hash(istate);
|
||||||
cache_tree_free(&(istate->cache_tree));
|
cache_tree_free(&(istate->cache_tree));
|
||||||
istate->initialized = 0;
|
istate->initialized = 0;
|
||||||
free(istate->cache);
|
FREE_AND_NULL(istate->cache);
|
||||||
istate->cache = NULL;
|
|
||||||
istate->cache_alloc = 0;
|
istate->cache_alloc = 0;
|
||||||
discard_split_index(istate);
|
discard_split_index(istate);
|
||||||
free_untracked_cache(istate->untracked);
|
free_untracked_cache(istate->untracked);
|
||||||
@ -2610,8 +2609,7 @@ void *read_blob_data_from_index(const struct index_state *istate,
|
|||||||
|
|
||||||
void stat_validity_clear(struct stat_validity *sv)
|
void stat_validity_clear(struct stat_validity *sv)
|
||||||
{
|
{
|
||||||
free(sv->sd);
|
FREE_AND_NULL(sv->sd);
|
||||||
sv->sd = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int stat_validity_check(struct stat_validity *sv, const char *path)
|
int stat_validity_check(struct stat_validity *sv, const char *path)
|
||||||
|
@ -1891,8 +1891,7 @@ void ref_array_clear(struct ref_array *array)
|
|||||||
|
|
||||||
for (i = 0; i < array->nr; i++)
|
for (i = 0; i < array->nr; i++)
|
||||||
free_array_item(array->items[i]);
|
free_array_item(array->items[i]);
|
||||||
free(array->items);
|
FREE_AND_NULL(array->items);
|
||||||
array->items = NULL;
|
|
||||||
array->nr = array->alloc = 0;
|
array->nr = array->alloc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2945,8 +2945,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
|
|||||||
head_oid.hash, &head_type);
|
head_oid.hash, &head_type);
|
||||||
|
|
||||||
if (head_ref && !(head_type & REF_ISSYMREF)) {
|
if (head_ref && !(head_type & REF_ISSYMREF)) {
|
||||||
free(head_ref);
|
FREE_AND_NULL(head_ref);
|
||||||
head_ref = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -82,9 +82,8 @@ static void clear_ref_dir(struct ref_dir *dir)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < dir->nr; i++)
|
for (i = 0; i < dir->nr; i++)
|
||||||
free_ref_entry(dir->entries[i]);
|
free_ref_entry(dir->entries[i]);
|
||||||
free(dir->entries);
|
FREE_AND_NULL(dir->entries);
|
||||||
dir->sorted = dir->nr = dir->alloc = 0;
|
dir->sorted = dir->nr = dir->alloc = 0;
|
||||||
dir->entries = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ref_entry *create_dir_entry(struct ref_cache *cache,
|
struct ref_entry *create_dir_entry(struct ref_cache *cache,
|
||||||
|
@ -66,8 +66,7 @@ static char *read_ref_note(const struct object_id *oid)
|
|||||||
else if (!msglen || type != OBJ_BLOB) {
|
else if (!msglen || type != OBJ_BLOB) {
|
||||||
error("Note contains unusable content. "
|
error("Note contains unusable content. "
|
||||||
"Is something else using this notes tree? %s", notes_ref);
|
"Is something else using this notes tree? %s", notes_ref);
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
free_notes(NULL);
|
free_notes(NULL);
|
||||||
return msg;
|
return msg;
|
||||||
|
3
rerere.c
3
rerere.c
@ -40,9 +40,8 @@ static void free_rerere_dirs(void)
|
|||||||
free(rerere_dir[i]->status);
|
free(rerere_dir[i]->status);
|
||||||
free(rerere_dir[i]);
|
free(rerere_dir[i]);
|
||||||
}
|
}
|
||||||
free(rerere_dir);
|
FREE_AND_NULL(rerere_dir);
|
||||||
rerere_dir_nr = rerere_dir_alloc = 0;
|
rerere_dir_nr = rerere_dir_alloc = 0;
|
||||||
rerere_dir = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_rerere_id(struct string_list_item *item)
|
static void free_rerere_id(struct string_list_item *item)
|
||||||
|
@ -1212,8 +1212,7 @@ struct todo_list {
|
|||||||
static void todo_list_release(struct todo_list *todo_list)
|
static void todo_list_release(struct todo_list *todo_list)
|
||||||
{
|
{
|
||||||
strbuf_release(&todo_list->buf);
|
strbuf_release(&todo_list->buf);
|
||||||
free(todo_list->items);
|
FREE_AND_NULL(todo_list->items);
|
||||||
todo_list->items = NULL;
|
|
||||||
todo_list->nr = todo_list->alloc = 0;
|
todo_list->nr = todo_list->alloc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +35,7 @@ int oid_array_lookup(struct oid_array *array, const struct object_id *oid)
|
|||||||
|
|
||||||
void oid_array_clear(struct oid_array *array)
|
void oid_array_clear(struct oid_array *array)
|
||||||
{
|
{
|
||||||
free(array->oid);
|
FREE_AND_NULL(array->oid);
|
||||||
array->oid = NULL;
|
|
||||||
array->nr = 0;
|
array->nr = 0;
|
||||||
array->alloc = 0;
|
array->alloc = 0;
|
||||||
array->sorted = 0;
|
array->sorted = 0;
|
||||||
|
@ -611,8 +611,7 @@ char *compute_alternate_path(const char *path, struct strbuf *err)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (seen_error) {
|
if (seen_error) {
|
||||||
free(ref_git);
|
FREE_AND_NULL(ref_git);
|
||||||
ref_git = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref_git;
|
return ref_git;
|
||||||
|
@ -167,10 +167,9 @@ void merge_base_index(struct index_state *istate)
|
|||||||
|
|
||||||
ewah_free(si->delete_bitmap);
|
ewah_free(si->delete_bitmap);
|
||||||
ewah_free(si->replace_bitmap);
|
ewah_free(si->replace_bitmap);
|
||||||
free(si->saved_cache);
|
FREE_AND_NULL(si->saved_cache);
|
||||||
si->delete_bitmap = NULL;
|
si->delete_bitmap = NULL;
|
||||||
si->replace_bitmap = NULL;
|
si->replace_bitmap = NULL;
|
||||||
si->saved_cache = NULL;
|
|
||||||
si->saved_cache_nr = 0;
|
si->saved_cache_nr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,8 +242,7 @@ static int disconnect_helper(struct transport *transport)
|
|||||||
close(data->helper->out);
|
close(data->helper->out);
|
||||||
fclose(data->out);
|
fclose(data->out);
|
||||||
res = finish_command(data->helper);
|
res = finish_command(data->helper);
|
||||||
free(data->helper);
|
FREE_AND_NULL(data->helper);
|
||||||
data->helper = NULL;
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -711,43 +710,35 @@ static int push_update_ref_status(struct strbuf *buf,
|
|||||||
|
|
||||||
if (!strcmp(msg, "no match")) {
|
if (!strcmp(msg, "no match")) {
|
||||||
status = REF_STATUS_NONE;
|
status = REF_STATUS_NONE;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "up to date")) {
|
else if (!strcmp(msg, "up to date")) {
|
||||||
status = REF_STATUS_UPTODATE;
|
status = REF_STATUS_UPTODATE;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "non-fast forward")) {
|
else if (!strcmp(msg, "non-fast forward")) {
|
||||||
status = REF_STATUS_REJECT_NONFASTFORWARD;
|
status = REF_STATUS_REJECT_NONFASTFORWARD;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "already exists")) {
|
else if (!strcmp(msg, "already exists")) {
|
||||||
status = REF_STATUS_REJECT_ALREADY_EXISTS;
|
status = REF_STATUS_REJECT_ALREADY_EXISTS;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "fetch first")) {
|
else if (!strcmp(msg, "fetch first")) {
|
||||||
status = REF_STATUS_REJECT_FETCH_FIRST;
|
status = REF_STATUS_REJECT_FETCH_FIRST;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "needs force")) {
|
else if (!strcmp(msg, "needs force")) {
|
||||||
status = REF_STATUS_REJECT_NEEDS_FORCE;
|
status = REF_STATUS_REJECT_NEEDS_FORCE;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "stale info")) {
|
else if (!strcmp(msg, "stale info")) {
|
||||||
status = REF_STATUS_REJECT_STALE;
|
status = REF_STATUS_REJECT_STALE;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(msg, "forced update")) {
|
else if (!strcmp(msg, "forced update")) {
|
||||||
forced = 1;
|
forced = 1;
|
||||||
free(msg);
|
FREE_AND_NULL(msg);
|
||||||
msg = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,8 +1146,7 @@ void transport_unlock_pack(struct transport *transport)
|
|||||||
{
|
{
|
||||||
if (transport->pack_lockfile) {
|
if (transport->pack_lockfile) {
|
||||||
unlink_or_warn(transport->pack_lockfile);
|
unlink_or_warn(transport->pack_lockfile);
|
||||||
free(transport->pack_lockfile);
|
FREE_AND_NULL(transport->pack_lockfile);
|
||||||
transport->pack_lockfile = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +141,7 @@ static struct combine_diff_path *path_appendnew(struct combine_diff_path *last,
|
|||||||
/* if last->next is !NULL - it is a pre-allocated memory, we can reuse */
|
/* if last->next is !NULL - it is a pre-allocated memory, we can reuse */
|
||||||
p = last->next;
|
p = last->next;
|
||||||
if (p && (alloclen > (intptr_t)p->next)) {
|
if (p && (alloclen > (intptr_t)p->next)) {
|
||||||
free(p);
|
FREE_AND_NULL(p);
|
||||||
p = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@ -559,8 +558,7 @@ struct combine_diff_path *diff_tree_paths(
|
|||||||
* (see path_appendnew() for details about why)
|
* (see path_appendnew() for details about why)
|
||||||
*/
|
*/
|
||||||
if (p->next) {
|
if (p->next) {
|
||||||
free(p->next);
|
FREE_AND_NULL(p->next);
|
||||||
p->next = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
3
tree.c
3
tree.c
@ -234,8 +234,7 @@ int parse_tree_gently(struct tree *item, int quiet_on_missing)
|
|||||||
|
|
||||||
void free_tree_buffer(struct tree *tree)
|
void free_tree_buffer(struct tree *tree)
|
||||||
{
|
{
|
||||||
free(tree->buffer);
|
FREE_AND_NULL(tree->buffer);
|
||||||
tree->buffer = NULL;
|
|
||||||
tree->size = 0;
|
tree->size = 0;
|
||||||
tree->object.parsed = 0;
|
tree->object.parsed = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user