Cycles: Fix static initialization order fiasco
Initialization order of global stats and node types was not strictly defined and it was possible to have node types initialized first and stats after that. This will zero out memory which was allocated from the statistics causing assert failure when de-initializing node types.
This commit is contained in:
parent
f55221e0a1
commit
f0adb875cf
|
@ -19,7 +19,7 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
static Stats global_stats;
|
||||
static Stats global_stats(Stats::static_init);
|
||||
|
||||
/* Internal API. */
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
class Stats {
|
||||
public:
|
||||
enum static_init_t { static_init = 0 };
|
||||
|
||||
Stats() : mem_used(0), mem_peak(0) {}
|
||||
explicit Stats(static_init_t) {}
|
||||
|
||||
void mem_alloc(size_t size) {
|
||||
atomic_add_z(&mem_used, size);
|
||||
|
|
Loading…
Reference in New Issue