summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-06-15 21:06:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-15 21:56:39 (GMT)
commit481df65f4f72582369eea8d002070c5dff38f8e6 (patch)
treea3fb4da57f398d6d6fd9530997384b933afd9ad2 /contrib/coccinelle
parent97e2ff464302565877a00b8a9aa6a2d85bd1445e (diff)
downloadgit-481df65f4f72582369eea8d002070c5dff38f8e6.zip
git-481df65f4f72582369eea8d002070c5dff38f8e6.tar.gz
git-481df65f4f72582369eea8d002070c5dff38f8e6.tar.bz2
git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
Add a FREE_AND_NULL() wrapper marco for the common pattern of freeing a pointer and assigning NULL to it right afterwards. The implementation is similar to the (currently unused) XDL_PTRFREE macro in xdiff/xmacros.h added in commit 3443546f6e ("Use a *real* built-in diff generator", 2006-03-24). The only difference is that free() is called unconditionally, see [1]. See [2] for a suggested alternative which does this via a function instead of a macro. As covered in replies to that message, while it's a viable approach, it would introduce caveats which this approach doesn't have, so that potential change is left to a future follow-up change. This merely allows us to translate exactly what we're doing now to a less verbose & idiomatic form using a macro, while guaranteeing that we don't introduce any functional changes. 1. <alpine.DEB.2.20.1608301948310.129229@virtualbox> (http://public-inbox.org/git/alpine.DEB.2.20.1608301948310.129229@virtualbox/) 2. <20170610032143.GA7880@starla> (https://public-inbox.org/git/20170610032143.GA7880@starla/) Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/coccinelle')
0 files changed, 0 insertions, 0 deletions