Fix GetClients() const correctness

It’s dangerous to give a non-const reference to an internal
container that the API users are not supposed to modify.
This commit is contained in:
J-P Nurmi
2014-10-01 20:28:59 +02:00
parent 705e79f808
commit 4fe249280e
8 changed files with 17 additions and 17 deletions

View File

@@ -271,7 +271,7 @@ void CClient::ReadLine(const CString& sData) {
// Relay to the rest of the clients that may be connected to this user
if (m_pNetwork->IsChan(sTarget)) {
vector<CClient*>& vClients = GetClients();
const vector<CClient*>& vClients = GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
@@ -325,7 +325,7 @@ void CClient::ReadLine(const CString& sData) {
}
// Relay to the rest of the clients that may be connected to this user
vector<CClient*>& vClients = GetClients();
const vector<CClient*>& vClients = GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
@@ -394,7 +394,7 @@ void CClient::ReadLine(const CString& sData) {
// Relay to the rest of the clients that may be connected to this user
if (m_pNetwork->IsChan(sTarget)) {
vector<CClient*>& vClients = GetClients();
const vector<CClient*>& vClients = GetClients();
for (unsigned int a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
@@ -575,7 +575,7 @@ void CClient::SetNetwork(CIRCNetwork* pNetwork, bool bDisconnect, bool bReconnec
}
}
vector<CClient*>& CClient::GetClients() {
const vector<CClient*>& CClient::GetClients() const {
if (m_pNetwork) {
return m_pNetwork->GetClients();
}