Skip to content

Commit 0d8a7d2

Browse files
authored
Merge pull request #75 from kaimast/master
Fix simulator under GCC6 Signed-off-by: Lili Zhang <[email protected]>
2 parents 2cd3c73 + 7e00ad3 commit 0d8a7d2

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

psw/urts/node.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737

3838
template<class T1, class T2>
3939
Node<T1, T2>::Node(const T1& k, const T2& v)
40+
: key(k), value(v), next(nullptr)
4041
{
41-
this->key = k;
42-
this->value = v;
43-
this->next = NULL;
4442
}
4543

4644
template<class T1, class T2>
@@ -71,14 +69,11 @@ Node<T1, T2>* Node<T1, T2>::Remove(const T1& k)
7169
template<class T1, class T2>
7270
Node<T1, T2>* Node<T1, T2>::Find(const T1& k)
7371
{
74-
Node<T1, T2>* c = this;
75-
if (c == NULL) return NULL;
76-
while (c != NULL) {
72+
for(auto c = this; c != nullptr; c = c->next) {
7773
if (c->key == k)
78-
break;
79-
c = c->next;
74+
return c;
8075
}
81-
return c;
76+
return nullptr;
8277
}
8378

8479

psw/urts/node.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ template<class T1, class T2>
3939
class Node: private Uncopyable
4040
{
4141
public:
42-
T1 key;
43-
T2 value;
42+
const T1 key;
43+
const T2 value;
44+
4445
Node<T1, T2> * next;
4546

4647
Node();
4748
Node(const T1& key, const T2& value);
4849

4950
bool InsertNext(Node<T1, T2>* p);
51+
5052
Node<T1, T2>* Find(const T1& key);
5153
Node<T1, T2>* Remove(const T1& key);
5254
};

psw/urts/tcs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,15 @@ int CTrustThreadPool::bind_thread(const se_thread_id_t thread_id, CTrustThread
150150

151151
CTrustThread * CTrustThreadPool::get_bound_thread(const se_thread_id_t thread_id)
152152
{
153-
CTrustThread *trust_thread = NULL;
153+
CTrustThread *trust_thread = nullptr;
154154

155-
Node<se_thread_id_t, CTrustThread*>* it = m_thread_list->Find(thread_id);
156-
if(it != NULL)
157-
trust_thread = it->value;
155+
if(m_thread_list)
156+
{
157+
auto it = m_thread_list->Find(thread_id);
158+
159+
if(it)
160+
trust_thread = it->value;
161+
}
158162

159163
return trust_thread;
160164
}

0 commit comments

Comments
 (0)