Revision d64ea0f83bd7e676778f833c57f969a94518a28d authored by Jeff King on 13 January 2015, 01:57:37 UTC, committed by Junio C Hamano on 13 January 2015, 18:03:30 UTC
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>
1 parent 1da1e07
History
File Mode Size
araxis -rw-r--r-- 392 bytes
bc3 -rw-r--r-- 401 bytes
codecompare -rw-r--r-- 387 bytes
deltawalker -rw-r--r-- 628 bytes
diffmerge -rw-r--r-- 286 bytes
diffuse -rw-r--r-- 282 bytes
ecmerge -rw-r--r-- 340 bytes
emerge -rw-r--r-- 415 bytes
gvimdiff -rw-r--r-- 29 bytes
gvimdiff2 -rw-r--r-- 29 bytes
gvimdiff3 -rw-r--r-- 29 bytes
kdiff3 -rw-r--r-- 499 bytes
kompare -rw-r--r-- 83 bytes
meld -rw-r--r-- 680 bytes
opendiff -rw-r--r-- 301 bytes
p4merge -rw-r--r-- 651 bytes
tkdiff -rw-r--r-- 224 bytes
tortoisemerge -rw-r--r-- 638 bytes
vimdiff -rw-r--r-- 878 bytes
vimdiff2 -rw-r--r-- 29 bytes
vimdiff3 -rw-r--r-- 29 bytes
xxdiff -rw-r--r-- 618 bytes

back to top