summaryrefslogtreecommitdiff
path: root/notes-cache.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-01-12 20:57:37 -0500
committerJunio C Hamano <gitster@pobox.com>2015-01-13 10:03:30 -0800
commitd64ea0f83bd7e676778f833c57f969a94518a28d (patch)
treea823ee7016046bdd3f6d2d9454b6a07260f28182 /notes-cache.c
parent1da1e07c835e900337714cfad6c32a8dc0b36ac3 (diff)
downloadgit-d64ea0f83bd7e676778f833c57f969a94518a28d.tar.gz
git-compat-util: add xstrdup_or_null helper
It's a common idiom to duplicate a string if it is non-NULL, or pass a literal NULL through. This is already a one-liner in C, but you do have to repeat the name of the string twice. So if there's a function call, you must write: const char *x = some_fun(...); return x ? xstrdup(x) : NULL; instead of (with this patch) just: return xstrdup_or_null(some_fun(...)); Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes-cache.c')
0 files changed, 0 insertions, 0 deletions