diff options
author | frosch <frosch@openttd.org> | 2015-03-07 18:27:01 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2015-03-07 18:27:01 +0000 |
commit | 780e5959331b39eda19868126af41398a904818b (patch) | |
tree | e2d592a1b2ec24af7ae1190c9ef970289b2e8e03 /src/linkgraph/mcf.cpp | |
parent | e77de936366fd4a0773386b8bdbe5bd6da354c89 (diff) | |
download | openttd-780e5959331b39eda19868126af41398a904818b.tar.xz |
(svn r27178) -Fix [FS#5969]: Data race due to lazy initialisation of objects.
Diffstat (limited to 'src/linkgraph/mcf.cpp')
-rw-r--r-- | src/linkgraph/mcf.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index bd3794a63..6fed7adea 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -148,15 +148,14 @@ public: */ void SetNode(NodeID source, NodeID node) { - static const FlowStat::SharesMap empty; const FlowStatMap &flows = this->job[node].Flows(); FlowStatMap::const_iterator it = flows.find(this->job[source].Station()); if (it != flows.end()) { this->it = it->second.GetShares()->begin(); this->end = it->second.GetShares()->end(); } else { - this->it = empty.begin(); - this->end = empty.end(); + this->it = FlowStat::empty_sharesmap.begin(); + this->end = FlowStat::empty_sharesmap.end(); } } @@ -379,11 +378,10 @@ void MCF1stPass::EliminateCycle(PathVector &path, Path *cycle_begin, uint flow) */ bool MCF1stPass::EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id) { - static Path *invalid_path = new Path(INVALID_NODE, true); Path *at_next_pos = path[next_id]; /* this node has already been searched */ - if (at_next_pos == invalid_path) return false; + if (at_next_pos == Path::invalid_path) return false; if (at_next_pos == NULL) { /* Summarize paths; add up the paths with the same source and next hop @@ -431,7 +429,7 @@ bool MCF1stPass::EliminateCycles(PathVector &path, NodeID origin_id, NodeID next * could be found in this branch, thus it has to be searched again next * time we spot it. */ - path[next_id] = found ? NULL : invalid_path; + path[next_id] = found ? NULL : Path::invalid_path; return found; } |