From d1fa4d5ccace79897a64c25b3423939fe276d096497402afc091b7789c80dc28 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 2 Mar 2025 02:09:15 -0500 Subject: [PATCH] Another string simplification. At some point using `std::filesystem::path` would be warranted. Better to simply clean up memory issues first, though. Then we can see what changes. --- src/dillo.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dillo.cc b/src/dillo.cc index afa94d5..fc4a08b 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -370,17 +370,18 @@ static void setColors() */ static DilloUrl *makeStartUrl(char *str, bool local) { + using namespace std::literals::string_literals; std::string url_str; - char *p; + std::string p; DilloUrl *start_url; /* Relative path to a local file? */ - p = (*str == '/') ? dStrdup(str) : - dStrconcat(Paths::getOldWorkingDir(), "/", str, NULL); + p = (*str == '/') ? str : + Paths::getOldWorkingDir() + "/"s + str; - if (access(p, F_OK) == 0) { + if (access(p.c_str(), F_OK) == 0) { /* absolute path may have non-URL characters */ - url_str = a_Misc_escape_chars(p, "% #"); + url_str = a_Misc_escape_chars(p.c_str(), "% #"); start_url = a_Url_new(url_str.c_str() + 1, "file:/"); } else { /* Not a file, filter URL string */ @@ -389,7 +390,6 @@ static DilloUrl *makeStartUrl(char *str, bool local) dFree( tmp ); start_url = a_Url_new(url_str.c_str(), NULL); } - dFree(p); if (local) a_Url_set_flags(start_url, URL_FLAGS(start_url) | URL_SpamSafe);