Skip to contentSkip to conversation

Replace remaining instances of strdup with xstrdup.

PATCH New James Bowes 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replace remaining instances of strdup with xstrdup.

---

This is a blatant copy of Shawn's patch. I don't know if there's a reason these are still strdup. If there is, please ignore this patch :)

 builtin-log.c |    2 +-
 commit.c      |    2 +-
 revision.c    |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
builtin-log.c +1 -1
index 865832c..71df957 100644
@@ -35,7 +35,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 		if (!prefixcmp(arg, "--encoding=")) {
 			arg += 11;
 			if (strcmp(arg, "none"))
-				git_log_output_encoding = strdup(arg);
+				git_log_output_encoding = xstrdup(arg);
 			else
 				git_log_output_encoding = "";
 		}
commit.c +1 -1
index 5b9234e..718e568 100644
@@ -706,7 +706,7 @@ static char *logmsg_reencode(const struct commit *commit,
 	encoding = get_header(commit, "encoding");
 	use_encoding = encoding ? encoding : utf8;
 	if (!strcmp(use_encoding, output_encoding))
-		out = strdup(commit->buffer);
+		out = xstrdup(commit->buffer);
 	else
 		out = reencode_string(commit->buffer,
 				      output_encoding, use_encoding);
revision.c +1 -1
index bcdb6a1..c680dcb 100644
@@ -1038,7 +1038,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 			if (!prefixcmp(arg, "--encoding=")) {
 				arg += 11;
 				if (strcmp(arg, "none"))
-					git_log_output_encoding = strdup(arg);
+					git_log_output_encoding = xstrdup(arg);
 				else
 					git_log_output_encoding = "";
 				continue;
Signature · 1 line
1.5.1.rc1.1.g504b