mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user