From 1e4ce4cdf86990d21197ca354a01d68f310db9a0 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:27:14 -0700 Subject: Pass request strings on without copying them --- source/ui-blame.c | 11 +++-------- source/ui-commit.c | 7 ++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/source/ui-blame.c b/source/ui-blame.c index 48cbf8e..efa9470 100644 --- a/source/ui-blame.c +++ b/source/ui-blame.c @@ -24,7 +24,7 @@ enum blame_target { }; struct walk_tree_context { - char *rev; + const char *rev; int match_baselen; enum blame_target found; }; @@ -338,12 +338,9 @@ static void print_blame_page(const struct object_id *oid, const char *path, html("
");
 	if (ctx.repo->source_filter) {
-		char *filter_arg = xstrdup(filename);
-
-		cgit_open_filter(ctx.repo->source_filter, filter_arg);
+		cgit_open_filter(ctx.repo->source_filter, filename);
 		html_raw(buf, size);
 		cgit_close_filter(ctx.repo->source_filter);
-		free(filter_arg);
 	} else {
 		html_blob_txt(buf, size);
 	}
@@ -428,7 +425,7 @@ void cgit_print_blame(void)
 		return;
 	}
 
-	walk.rev = xstrdup(rev);
+	walk.rev = rev;
 	walk.match_baselen = path_items.match ? basedir_len(path_items.match) : -1;
 
 	read_tree(the_repository, repo_get_commit_tree(the_repository, commit), &paths, walk_tree, &walk);
@@ -436,6 +433,4 @@ void cgit_print_blame(void)
 		cgit_print_error_page(404, "Not Found", "Not found");
 	else if (walk.found == TARGET_FOLDER)
 		cgit_print_error_page(404, "Not Found", "Blame is not available for a directory");
-
-	free(walk.rev);
 }
diff --git a/source/ui-commit.c b/source/ui-commit.c
index 63f2b7e..ce00cf0 100644
--- a/source/ui-commit.c
+++ b/source/ui-commit.c
@@ -247,7 +247,6 @@ void cgit_print_commit(char *hex, const char *prefix)
 	struct object_id oid, first_oid;
 	const char *commit_hex;
 	char *first_parent;
-	char *tree_rev;
 	int parents;
 
 	if (!hex)
@@ -293,13 +292,11 @@ void cgit_print_commit(char *hex, const char *prefix)
 	parents = print_parent_rows(commit, hex, prefix, &first_oid);
 
 	html("tree
"); - tree_rev = xstrdup(hex); - cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, tree_rev, NULL); + cgit_tree_link(oid_to_hex(get_commit_tree_oid(commit)), NULL, NULL, ctx.qry.head, hex, NULL); if (prefix) { html(" /"); - cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, tree_rev, prefix); + cgit_tree_link(prefix, NULL, NULL, ctx.qry.head, hex, prefix); } - free(tree_rev); html("
\n"); if (ctx.repo->snapshots) { -- cgit