Skip to content

Commit 7ae96e3

Browse files
committed
Merge branch 'ab/unconditional-free-and-null'
Code clean-up. * ab/unconditional-free-and-null: refactor various if (x) FREE_AND_NULL(x) to just FREE_AND_NULL(x)
2 parents a988ce9 + ce528de commit 7ae96e3

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

blame.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,7 @@ static void fill_origin_blob(struct diff_options *opt,
337337

338338
static void drop_origin_blob(struct blame_origin *o)
339339
{
340-
if (o->file.ptr) {
341-
FREE_AND_NULL(o->file.ptr);
342-
}
340+
FREE_AND_NULL(o->file.ptr);
343341
}
344342

345343
/*

branch.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
2525
tracking->remote = remote->name;
2626
} else {
2727
free(tracking->spec.src);
28-
if (tracking->src) {
29-
FREE_AND_NULL(tracking->src);
30-
}
28+
FREE_AND_NULL(tracking->src);
3129
}
3230
tracking->spec.src = NULL;
3331
}

http.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,9 +2418,7 @@ void release_http_object_request(struct http_object_request *freq)
24182418
close(freq->localfile);
24192419
freq->localfile = -1;
24202420
}
2421-
if (freq->url != NULL) {
2422-
FREE_AND_NULL(freq->url);
2423-
}
2421+
FREE_AND_NULL(freq->url);
24242422
if (freq->slot != NULL) {
24252423
freq->slot->callback_func = NULL;
24262424
freq->slot->callback_data = NULL;

tree-diff.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,7 @@ struct combine_diff_path *diff_tree_paths(
557557
* free pre-allocated last element, if any
558558
* (see path_appendnew() for details about why)
559559
*/
560-
if (p->next) {
561-
FREE_AND_NULL(p->next);
562-
}
560+
FREE_AND_NULL(p->next);
563561

564562
return p;
565563
}

0 commit comments

Comments
 (0)