X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b6d29644d566a866a7cec0ab4c601700fdb47020..3f4f5e63dadc0023c0a02a08af8e9e9801b38e8e:/src/xbt/log.cpp diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index 78fd4d5fa4..d21ea0e07b 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -98,21 +98,24 @@ void xbt_log_init(int *argc, char **argv) } } -static void log_cat_exit(const s_xbt_log_category_t* cat) +static void log_cat_exit(xbt_log_category_t cat) { if (cat->appender) { if (cat->appender->free_) cat->appender->free_(cat->appender); xbt_free(cat->appender); + cat->appender = nullptr; } if (cat->layout) { if (cat->layout->free_) cat->layout->free_(cat->layout); xbt_free(cat->layout); + cat->layout = nullptr; } - for (auto const* child = cat->firstChild; child != nullptr; child = child->nextSibling) + for (auto* child = cat->firstChild; child != nullptr; child = child->nextSibling) log_cat_exit(child); + cat->firstChild = nullptr; } static void xbt_log_postexit(void) @@ -232,7 +235,7 @@ int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority return priority >= category->threshold; static std::recursive_mutex log_cat_init_mutex; - log_cat_init_mutex.lock(); + const std::scoped_lock lock(log_cat_init_mutex); XBT_DEBUG("Initializing category '%s' (firstChild=%s, nextSibling=%s)", category->name, (category->firstChild ? category->firstChild->name : "none"), @@ -276,7 +279,6 @@ int _xbt_log_cat_init(xbt_log_category_t category, e_xbt_log_priority_t priority } category->initialized = 1; - log_cat_init_mutex.unlock(); return priority >= category->threshold; }