From: Junio C Hamano Date: Sat, 24 Jun 2017 21:28:41 +0000 (-0700) Subject: Merge branch 'ab/free-and-null' X-Git-Tag: v2.14.0-rc0~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=50f03c6676ed5ea040dd53272882d3aac2ee1b48;p=thirdparty%2Fgit.git 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 --- 50f03c6676ed5ea040dd53272882d3aac2ee1b48 diff --cc grep.c index 1fca83be86,909f35a984..98733db623 --- a/grep.c +++ b/grep.c @@@ -1953,10 -1773,9 +1950,9 @@@ void grep_source_clear_data(struct grep { switch (gs->type) { case GREP_SOURCE_FILE: - case GREP_SOURCE_SHA1: + case GREP_SOURCE_OID: case GREP_SOURCE_SUBMODULE: - free(gs->buf); - gs->buf = NULL; + FREE_AND_NULL(gs->buf); gs->size = 0; break; case GREP_SOURCE_BUF: