diff options
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/util.cpp b/src/util.cpp index d198a5d..86435fa 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -22,6 +22,7 @@ #include <cinttypes> #include <string.h> +#include <mutex> #include "md5.h" @@ -1664,15 +1665,16 @@ static CharAroundSpace g_charAroundSpace; // Note: this function is not reentrant due to the use of static buffer! QCString removeRedundantWhiteSpace(const QCString &s) { - static bool cliSupport = Config_getBool(CPP_CLI_SUPPORT); - static bool vhdl = Config_getBool(OPTIMIZE_OUTPUT_VHDL); + bool cliSupport = Config_getBool(CPP_CLI_SUPPORT); + bool vhdl = Config_getBool(OPTIMIZE_OUTPUT_VHDL); if (s.isEmpty() || vhdl) return s; // We use a static character array to // improve the performance of this function - static char *growBuf = 0; - static int growBufLen = 0; + // and thread_local is needed to make it multi-thread safe + static THREAD_LOCAL char *growBuf = 0; + static THREAD_LOCAL int growBufLen = 0; if ((int)s.length()*3>growBufLen) // For input character we produce at most 3 output characters, { growBufLen = s.length()*3; @@ -4480,11 +4482,19 @@ struct FindFileCacheElem static QCache<FindFileCacheElem> g_findFileDefCache(5000); +#if MULTITHREADED_INPUT +static std::mutex g_findFileDefMutex; +#endif + FileDef *findFileDef(const FileNameLinkedMap *fnMap,const char *n,bool &ambig) { ambig=FALSE; if (n==0) return 0; +#if MULTITHREADED_INPUT + std::unique_lock<std::mutex> lock(g_findFileDefMutex); +#endif + const int maxAddrSize = 20; char addr[maxAddrSize]; qsnprintf(addr,maxAddrSize,"%p:",(void*)fnMap); |