Remove some IMHO dangerous functions

Instead, these functions are now inlined into their only caller. This should
make the user and network destruction a little saner. At least I hope so...

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-08-29 12:52:21 +02:00
parent bd3e6d3f7b
commit 9c9e40a3d7
5 changed files with 40 additions and 63 deletions
+18 -26
View File
@@ -88,13 +88,28 @@ CUser::CUser(const CString& sUserName)
}
CUser::~CUser() {
DelNetworks();
// Delete modules (unloads all modules!)
delete m_pModules;
m_pModules = NULL;
DelClients();
// Delete networks
for (unsigned int c = 0; c < m_vIRCNetworks.size(); c++) {
CIRCNetwork* pNetwork = m_vIRCNetworks[c];
delete pNetwork;
}
m_vIRCNetworks.clear();
DelModules();
// Delete clients
for (unsigned int c = 0; c < m_vClients.size(); c++) {
CClient* pClient = m_vClients[c];
CZNC::Get().GetManager().DelSockByAddr(pClient);
}
m_vClients.clear();
CZNC::Get().GetManager().DelCronByAddr(m_pUserTimer);
CZNC::Get().AddBytesRead(BytesRead());
CZNC::Get().AddBytesWritten(BytesWritten());
}
template<class T>
@@ -395,11 +410,6 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
return true;
}
void CUser::DelModules() {
delete m_pModules;
m_pModules = NULL;
}
bool CUser::UpdateModule(const CString &sModule) {
const map<CString,CUser*>& Users = CZNC::Get().GetUserMap();
map<CString,CUser*>::const_iterator it;
@@ -427,24 +437,6 @@ bool CUser::UpdateModule(const CString &sModule) {
return !error;
}
void CUser::DelNetworks() {
for (unsigned int c = 0; c < m_vIRCNetworks.size(); c++) {
CIRCNetwork* pNetwork = m_vIRCNetworks[c];
delete pNetwork;
}
m_vIRCNetworks.clear();
}
void CUser::DelClients() {
for (unsigned int c = 0; c < m_vClients.size(); c++) {
CClient* pClient = m_vClients[c];
CZNC::Get().GetManager().DelSockByAddr(pClient);
}
m_vClients.clear();
}
CIRCNetwork* CUser::AddNetwork(const CString &sNetwork) {
if (!CIRCNetwork::IsValidNetwork(sNetwork) || FindNetwork(sNetwork)) {
return NULL;