aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjtimon <jtimon@blockstream.io>2014-09-01 00:01:54 +0200
committerjtimon <jtimon@blockstream.io>2014-09-21 21:21:09 +0200
commitf297479a1995bd147c21c58fca103cd3ab3e54c1 (patch)
tree90cfe04146edd89d723cf8ea09aa2c1a7bceee9e
parent934b153a2caba4071a614e5b3ef40feeaff631d4 (diff)
Reserve only one network specific cached path per session
-rw-r--r--src/util.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 0ac0f70a79..7bb65f6584 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -395,7 +395,7 @@ boost::filesystem::path GetDefaultDataDir()
#endif
}
-static boost::filesystem::path pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1];
+static boost::filesystem::path pathCached[2];
static CCriticalSection csPathCached;
const boost::filesystem::path &GetDataDir(bool fNetSpecific)
@@ -404,10 +404,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
LOCK(csPathCached);
- int nNet = CBaseChainParams::MAX_NETWORK_TYPES;
- if (fNetSpecific) nNet = BaseParams().NetworkID();
-
- fs::path &path = pathCached[nNet];
+ fs::path &path = pathCached[fNetSpecific ? 1 : 0];
// This can be called during exceptions by LogPrintf(), so we cache the
// value so we don't have to do memory allocations after that.
@@ -433,8 +430,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
void ClearDatadirCache()
{
- std::fill(&pathCached[0], &pathCached[CBaseChainParams::MAX_NETWORK_TYPES+1],
- boost::filesystem::path());
+ std::fill(&pathCached[0], &pathCached[2], boost::filesystem::path());
}
boost::filesystem::path GetConfigFile()