reduce asprint usage in gw_output_repo_tree
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 8317195..c3ad3f7 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -4121,14 +4121,11 @@ gw_output_repo_tree(struct gw_trans *gw_trans)
error = got_error_from_errno("asprintf");
goto done;
}
- if (asprintf(&href_blob,
- "?path=%s&action=%s&commit=%s&folder=%s",
- gw_trans->repo_name, gw_get_action_name(gw_trans),
- gw_trans->commit_id, build_folder) == -1) {
- error = got_error_from_errno("asprintf");
- goto done;
- }
+ href_blob = khttp_urlpart(NULL, NULL, "gotweb", "path",
+ gw_trans->repo_name, "action",
+ gw_get_action_name(gw_trans), "commit",
+ gw_trans->commit_id, "folder", build_folder, NULL);
kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
KATTR_ID, "tree_wrapper", KATTR__MAX);
if (kerr != KCGI_OK)
@@ -4163,25 +4160,18 @@ gw_output_repo_tree(struct gw_trans *gw_trans)
if (kerr != KCGI_OK)
goto done;
} else {
- if (asprintf(&href_blob,
- "?path=%s&action=%s&commit=%s&file=%s&folder=%s",
- gw_trans->repo_name, "blob", gw_trans->commit_id,
- got_tree_entry_get_name(te),
- gw_trans->repo_folder ?
- gw_trans->repo_folder : "") == -1) {
- error = got_error_from_errno("asprintf");
- goto done;
- }
- if (asprintf(&href_blame,
- "?path=%s&action=%s&commit=%s&file=%s&folder=%s",
- gw_trans->repo_name, "blame", gw_trans->commit_id,
- got_tree_entry_get_name(te),
- gw_trans->repo_folder ?
- gw_trans->repo_folder : "") == -1) {
- error = got_error_from_errno("asprintf");
- goto done;
- }
-
+ href_blob = khttp_urlpart(NULL, NULL, "gotweb", "path",
+ gw_trans->repo_name, "action", "blob", "commit",
+ gw_trans->commit_id, "file",
+ got_tree_entry_get_name(te), "folder",
+ gw_trans->repo_folder ? gw_trans->repo_folder : "",
+ NULL);
+ href_blame = khttp_urlpart(NULL, NULL, "gotweb", "path",
+ gw_trans->repo_name, "action", "blame", "commit",
+ gw_trans->commit_id, "file",
+ got_tree_entry_get_name(te), "folder",
+ gw_trans->repo_folder ? gw_trans->repo_folder : "",
+ NULL);
kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
KATTR_ID, "tree_wrapper", KATTR__MAX);
if (kerr != KCGI_OK)