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
sha1.c -rw-r--r-- 1.4 KB
sha1.h -rw-r--r-- 559 bytes
sha1ppc.S -rw-r--r-- 7.3 KB

back to top