diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-07-15 17:10:42 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2019-07-15 17:10:42 +0200 |
commit | 44fd459c799e393d13d664102cf381264c80649f (patch) | |
tree | c1471cf52f6f2a150830619c08b8bbb4f567dde8 | |
parent | 0e6c83027f24cdf7082606a5631468ad28f41574 (diff) | |
download | yosys-44fd459c799e393d13d664102cf381264c80649f.tar.gz yosys-44fd459c799e393d13d664102cf381264c80649f.tar.bz2 yosys-44fd459c799e393d13d664102cf381264c80649f.zip |
Redesign log_id_cache so that it doesn't keep IdString instances referenced, fixes #1178
Signed-off-by: Clifford Wolf <clifford@clifford.at>
-rw-r--r-- | kernel/log.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/log.cc b/kernel/log.cc index 1a2c89a9c..08ebe7af7 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -61,7 +61,7 @@ int log_force_debug = 0; int log_debug_suppressed = 0; vector<int> header_count; -pool<RTLIL::IdString> log_id_cache; +vector<char*> log_id_cache; vector<shared_str> string_buf; int string_buf_index = -1; @@ -69,6 +69,13 @@ static struct timeval initial_tv = { 0, 0 }; static bool next_print_log = false; static int log_newline_count = 0; +static void log_id_cache_clear() +{ + for (auto p : log_id_cache) + free(p); + log_id_cache.clear(); +} + #if defined(_WIN32) && !defined(__MINGW32__) // this will get time information and return it in timeval, simulating gettimeofday() int gettimeofday(struct timeval *tv, struct timezone *tz) @@ -414,7 +421,7 @@ void log_push() void log_pop() { header_count.pop_back(); - log_id_cache.clear(); + log_id_cache_clear(); string_buf.clear(); string_buf_index = -1; log_flush(); @@ -422,7 +429,7 @@ void log_pop() void log_checkpoint() { - log_id_cache.clear(); + log_id_cache_clear(); IdString::checkpoint(); log_flush(); } @@ -528,7 +535,7 @@ void log_reset_stack() { while (header_count.size() > 1) header_count.pop_back(); - log_id_cache.clear(); + log_id_cache_clear(); string_buf.clear(); string_buf_index = -1; log_flush(); @@ -587,8 +594,8 @@ const char *log_const(const RTLIL::Const &value, bool autoint) const char *log_id(RTLIL::IdString str) { - log_id_cache.insert(str); - const char *p = str.c_str(); + log_id_cache.push_back(strdup(str.c_str())); + const char *p = log_id_cache.back(); if (p[0] != '\\') return p; if (p[1] == '$' || p[1] == '\\' || p[1] == 0) |