refactor various if (x) FREE_AND_NULL(x) to just FREE_AND_NULL(x)
Change the few conditional uses of FREE_AND_NULL(x) to be unconditional. As noted in the standard[1] free(NULL) is perfectly valid, so we might as well leave this check up to the C library. 1. http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
53f9a3e157
commit
ce528de023
2
blame.c
2
blame.c
@ -313,10 +313,8 @@ 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) {
|
|
||||||
FREE_AND_NULL(o->file.ptr);
|
FREE_AND_NULL(o->file.ptr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Any merge of blames happens on lists of blames that arrived via
|
* Any merge of blames happens on lists of blames that arrived via
|
||||||
|
2
branch.c
2
branch.c
@ -25,10 +25,8 @@ static int find_tracked_branch(struct remote *remote, void *priv)
|
|||||||
tracking->remote = remote->name;
|
tracking->remote = remote->name;
|
||||||
} else {
|
} else {
|
||||||
free(tracking->spec.src);
|
free(tracking->spec.src);
|
||||||
if (tracking->src) {
|
|
||||||
FREE_AND_NULL(tracking->src);
|
FREE_AND_NULL(tracking->src);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
tracking->spec.src = NULL;
|
tracking->spec.src = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
http.c
2
http.c
@ -2418,9 +2418,7 @@ void release_http_object_request(struct http_object_request *freq)
|
|||||||
close(freq->localfile);
|
close(freq->localfile);
|
||||||
freq->localfile = -1;
|
freq->localfile = -1;
|
||||||
}
|
}
|
||||||
if (freq->url != NULL) {
|
|
||||||
FREE_AND_NULL(freq->url);
|
FREE_AND_NULL(freq->url);
|
||||||
}
|
|
||||||
if (freq->slot != NULL) {
|
if (freq->slot != NULL) {
|
||||||
freq->slot->callback_func = NULL;
|
freq->slot->callback_func = NULL;
|
||||||
freq->slot->callback_data = NULL;
|
freq->slot->callback_data = NULL;
|
||||||
|
@ -557,9 +557,7 @@ struct combine_diff_path *diff_tree_paths(
|
|||||||
* free pre-allocated last element, if any
|
* free pre-allocated last element, if any
|
||||||
* (see path_appendnew() for details about why)
|
* (see path_appendnew() for details about why)
|
||||||
*/
|
*/
|
||||||
if (p->next) {
|
|
||||||
FREE_AND_NULL(p->next);
|
FREE_AND_NULL(p->next);
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user