From 6a83d902073803c4141e02c53decf8c03e35da27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 15 Jun 2017 23:15:46 +0000 Subject: coccinelle: make use of the "type" FREE_AND_NULL() rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apply the result of the just-added coccinelle rule. This manually excludes a few occurrences, mostly things that resulted in many FREE_AND_NULL() on one line, that'll be manually fixed in a subsequent change. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- line-log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'line-log.c') diff --git a/line-log.c b/line-log.c index b9087814b8..79eded7363 100644 --- a/line-log.c +++ b/line-log.c @@ -610,8 +610,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args) line_log_data_insert(&ranges, full_name, begin, end); free_filespec(spec); - free(ends); - ends = NULL; + FREE_AND_NULL(ends); } for (p = ranges; p; p = p->next) -- cgit v1.2.3 From 88ce3ef636b1385e861ec0e9e2155248b999b032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 15 Jun 2017 23:15:49 +0000 Subject: *.[ch] refactoring: make use of the FREE_AND_NULL() macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace occurrences of `free(ptr); ptr = NULL` which weren't caught by the coccinelle rule. These fall into two categories: - free/NULL assignments one after the other which coccinelle all put on one line, which is functionally equivalent code, but very ugly. - manually spotted occurrences where the NULL assignment isn't right after the free() call. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- line-log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'line-log.c') diff --git a/line-log.c b/line-log.c index 79eded7363..2d60c347ca 100644 --- a/line-log.c +++ b/line-log.c @@ -34,9 +34,8 @@ void range_set_init(struct range_set *rs, size_t prealloc) void range_set_release(struct range_set *rs) { - free(rs->ranges); + FREE_AND_NULL(rs->ranges); rs->alloc = rs->nr = 0; - rs->ranges = NULL; } /* dst must be uninitialized! */ -- cgit v1.2.3