From 79b36ec07fe13d856ef31cb2315c6a20aeff7632 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 1 Nov 2018 04:24:32 +0000 Subject: [PATCH] added some internal comments about Mmgr::getDFL() --- qse/lib/cmn/Mmgr.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qse/lib/cmn/Mmgr.cpp b/qse/lib/cmn/Mmgr.cpp index 5f2b331d..55c7ead9 100644 --- a/qse/lib/cmn/Mmgr.cpp +++ b/qse/lib/cmn/Mmgr.cpp @@ -56,19 +56,22 @@ void* Mmgr::callocate (qse_size_t n, bool raise_exception) QSE_CPP_THREXCEPT1(Me #if 0 #if defined(__GNUC__) -static StdMmgr __attribute__((init_priority(101))) std_dfl_mmgr; +static StdMmgr __attribute__((init_priority(101))) std_dfl_mmgr; <- this solved the problem #else -static StdMmgr std_dfl_mmgr; +static StdMmgr std_dfl_mmgr; <-- has an issue for undefined initialization order #endif -Mmgr* Mmgr::dfl_mmgr = &std_dfl_mmgr; -//Mmgr* Mmgr::dfl_mmgr = StdMmgr::getInstance(); <--- has an issue with initialization order +Mmgr* Mmgr::dfl_mmgr = &std_dfl_mmgr; +//Mmgr* Mmgr::dfl_mmgr = StdMmgr::getInstance(); <--- has an issue as well +Mmgr* Mmgr::getDFL () QSE_CPP_NOEXCEPT +{ + return Mmgr::dfl_mmgr; +} #else // C++ initialization order across translation units are not defined. // so it's tricky to work around this... the init_priority attribute // can solve this problem. but it's compiler dependent. // Mmgr::getDFL() resets dfl_mmgr to &std_dfl_mmgr if it's NULL. Mmgr* Mmgr::dfl_mmgr = QSE_NULL; -#endif Mmgr* Mmgr::getDFL () QSE_CPP_NOEXCEPT { @@ -76,6 +79,7 @@ Mmgr* Mmgr::getDFL () QSE_CPP_NOEXCEPT Mmgr* mmgr = Mmgr::dfl_mmgr; return mmgr? mmgr: &std_dfl_mmgr; } +#endif void Mmgr::setDFL (Mmgr* mmgr) QSE_CPP_NOEXCEPT {