Context::~Context()
{
+ free(stats_file);
}
ArgsInfo args_info;
Config config;
+
+ // Full path to the statistics file in the subdirectory where the cached
+ // result belongs (<cache_dir>/<x>/stats).
+ char* stats_file = nullptr;
};
result_name_string,
".result")
.c_str());
- stats_file = format(
+ ctx.stats_file = format(
"%s/%c/stats", ctx.config.cache_dir().c_str(), result_name_string[0]);
}
failed();
}
stats_update_size(ctx,
- stats_file,
+ ctx.stats_file,
new_dest_stat.size_on_disk()
- orig_dest_stat.size_on_disk(),
orig_dest_stat ? 0 : 1);
// be done almost anywhere, but we might as well do it near the end as we
// save the stat call if we exit early.
{
- char* first_level_dir = x_dirname(stats_file);
+ char* first_level_dir = x_dirname(ctx.stats_file);
if (!create_cachedir_tag(first_level_dir) != 0) {
cc_log("Failed to create %s/CACHEDIR.TAG (%s)",
first_level_dir,
has_absolute_include_headers = false;
i_tmpfile = NULL;
free_and_nullify(cpp_stderr);
- free_and_nullify(stats_file);
output_is_precompiled_header = false;
}
// The name of the cpp stderr file.
char* cpp_stderr;
-// Full path to the statistics file in the subdirectory where the cached result
-// belongs (<cache_dir>/<x>/stats).
-char* stats_file = nullptr;
-
// The stats file to use for the manifest.
char* manifest_stats_file;
// variable descriptions are in the .cpp file
extern char* current_working_dir;
-extern char* stats_file;
+
extern unsigned lock_staleness_limit;
extern struct args* orig_args;
//
// 1: Introduced in ccache 4.0.
-extern char* stats_file;
-
const uint8_t k_result_magic[4] = {'c', 'C', 'r', 'S'};
const uint8_t k_result_version = 1;
auto new_stat = Stat::stat(raw_file);
stats_update_size(ctx,
- stats_file,
+ ctx.stats_file,
new_stat.size_on_disk() - old_stat.size_on_disk(),
(new_stat ? 1 : 0) - (old_stat ? 1 : 0));
}
#include <sys/types.h>
#include <unistd.h>
-extern char* stats_file;
extern unsigned lock_staleness_limit;
static struct counters* counter_updates;
}
struct counters* updates;
- if (sfile == stats_file) {
+ if (sfile == ctx.stats_file) {
init_counter_updates();
updates = counter_updates;
} else {
}
updates->data[STATS_NUMFILES] += files;
updates->data[STATS_TOTALSIZE] += size / 1024;
- if (sfile != stats_file) {
+ if (sfile != ctx.stats_file) {
stats_flush_to_file(ctx.config, sfile, updates);
counters_free(updates);
}
stats_flush(void* context)
{
Context& ctx = *static_cast<Context*>(context);
- stats_flush_to_file(ctx.config, stats_file, counter_updates);
+ stats_flush_to_file(ctx.config, ctx.stats_file, counter_updates);
counters_free(counter_updates);
counter_updates = NULL;
}