r++;
}
// p and q span the include file path.
- char* inc_path = x_strndup(p, q - p);
+ std::string inc_path(p, q - p);
if (!ctx.has_absolute_include_headers) {
ctx.has_absolute_include_headers = Util::is_absolute_path(inc_path);
}
- char* saved_inc_path = inc_path;
- inc_path = x_strdup(Util::make_relative_path(ctx, inc_path).c_str());
- free(saved_inc_path);
+ inc_path = Util::make_relative_path(ctx, inc_path);
bool should_hash_inc_path = true;
if (!ctx.config.hash_dir()) {
if (Util::starts_with(inc_path, ctx.apparent_cwd)
- && str_endswith(inc_path, "//")) {
+ && Util::ends_with(inc_path, "//")) {
// When compiling with -g or similar, GCC adds the absolute path to
// CWD like this:
//
}
remember_include_file(ctx, inc_path, hash, system, nullptr);
- free(inc_path);
p = q; // Everything of interest between p and q has been hashed now.
} else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c'
&& q[4] == 'b' && q[5] == 'i' && q[6] == 'n') {
Args act_cc;
Util::write_file("foo.c", "");
- ctx.config.set_base_dir(x_strdup("/")); // posix
+ ctx.config.set_base_dir("/"); // posix
// Windows path doesn't work concatenated.
std::string cwd = get_posix_path(ctx.actual_cwd);
std::string arg_string = fmt::format("cc -I{}/foo -c foo.c", cwd);