From 19e779cdf99b0a7efd2cfbef2e4ef125e5b0d324 Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Fri, 5 May 2023 01:02:35 +0000 Subject: [PATCH] core, logging: remove clean_up_without_threads and simplify clean_up --- src/conky.cc | 15 ++++----------- src/logging.h | 6 ++++-- src/main.cc | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 30c308cb..40336ee7 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -1828,7 +1828,7 @@ void main_loop() { llua_update_info(&info, active_update_interval()); } - clean_up(nullptr, nullptr); + clean_up(); #ifdef HAVE_SYS_INOTIFY_H if (inotify_fd != -1) { @@ -1850,7 +1850,7 @@ static void reload_config() { current_config.c_str(), getpid()); return; } - clean_up(nullptr, nullptr); + clean_up(); state = std::make_unique(); conky::export_symbols(*state); sleep(1); /* slight pause */ @@ -1868,10 +1868,8 @@ void free_specials(special_t *¤t) { clear_stored_graphs(); } -void clean_up_without_threads(void *memtofree1, void *memtofree2) { - free_and_zero(memtofree1); - free_and_zero(memtofree2); - +void clean_up(void) { + /* free_update_callbacks(); XXX: some new equivalent of this? */ free_and_zero(info.cpu_usage); for (auto output : display_outputs()) output->cleanup(); conky::shutdown_display_outputs(); @@ -1911,11 +1909,6 @@ void clean_up_without_threads(void *memtofree1, void *memtofree2) { state.reset(); } -void clean_up(void *memtofree1, void *memtofree2) { - /* free_update_callbacks(); XXX: some new equivalent of this? */ - clean_up_without_threads(memtofree1, memtofree2); -} - static void set_default_configurations() { update_uname(); info.memmax = 0; diff --git a/src/logging.h b/src/logging.h index 950fd40e..cae61d3e 100644 --- a/src/logging.h +++ b/src/logging.h @@ -61,7 +61,7 @@ class obj_create_error : public std::runtime_error { obj_create_error(const std::string &msg) : std::runtime_error(msg) {} }; -void clean_up(void *memtofree1, void *memtofree2); +void clean_up(void); template inline void gettextize_format(const char *format, Args &&...args) { @@ -84,7 +84,9 @@ template inline void CRIT_ERR(void *memtofree1, void *memtofree2, const char *format, Args &&...args) { NORM_ERR(format, args...); - clean_up(memtofree1, memtofree2); + free(memtofree1); + free(memtofree2); + clean_up(); exit(EXIT_FAILURE); } diff --git a/src/main.cc b/src/main.cc index 82458077..6c9d3b67 100644 --- a/src/main.cc +++ b/src/main.cc @@ -359,7 +359,7 @@ int main(int argc, char **argv) { return EXIT_FAILURE; } catch (obj_create_error &e) { std::cerr << e.what() << std::endl; - clean_up(nullptr, nullptr); + clean_up(); return EXIT_FAILURE; } catch (std::exception &e) { std::cerr << PACKAGE_NAME ": " << e.what() << std::endl;