builtin/apply.c: use xstrdup_or_null instead of null_strdup

This file had its own identical helper that predates xstrdup_or_null. Let's use the global one to avoid repetition. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 12, 2015 at 20:58 UTC 444069078687fc00586824a21eff9758fc4d0625
1 file changed +5 -10
builtin/apply.c
+5 -10
@@ -656,11 +656,6 @@ static size_t diff_timestamp_len(const char *line, size_t len)
656 return line + len - end;
657 }
658
659 -static char *null_strdup(const char *s)
660 -{
661 - return s ? xstrdup(s) : NULL;
662 -}
663 -
659 static char *find_name_common(const char *line, const char *def,
660 int p_value, const char *end, int terminate)
661 {
@@ -683,10 +678,10 @@ static char *find_name_common(const char *line, const char *def,
678 start = line;
679 }
680 if (!start)
686 - return squash_slash(null_strdup(def));
681 + return squash_slash(xstrdup_or_null(def));
682 len = line - start;
683 if (!len)
689 - return squash_slash(null_strdup(def));
684 + return squash_slash(xstrdup_or_null(def));
685
686 /*
687 * Generally we prefer the shorter name, especially
@@ -908,7 +903,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
903 patch->old_name = name;
904 } else {
905 patch->old_name = name;
911 - patch->new_name = null_strdup(name);
906 + patch->new_name = xstrdup_or_null(name);
907 }
908 }
909 if (!name)
@@ -997,7 +992,7 @@ static int gitdiff_delete(const char *line, struct patch *patch)
992 {
993 patch->is_delete = 1;
994 free(patch->old_name);
1000 - patch->old_name = null_strdup(patch->def_name);
995 + patch->old_name = xstrdup_or_null(patch->def_name);
996 return gitdiff_oldmode(line, patch);
997 }
998
@@ -1005,7 +1000,7 @@ static int gitdiff_newfile(const char *line, struct patch *patch)
1000 {
1001 patch->is_new = 1;
1002 free(patch->new_name);
1008 - patch->new_name = null_strdup(patch->def_name);
1003 + patch->new_name = xstrdup_or_null(patch->def_name);
1004 return gitdiff_newmode(line, patch);
1005 }
1006