Browse Source

Fixed minor memory leak/bug.

Added pop() ot ArrayList.
release/0.19
JustinAJ 9 years ago
parent
commit
5338777b91
  1. 12
      Jupiter/ArrayList.h
  2. 19
      Jupiter/IRC_Client.cpp
  3. BIN
      Release/Jupiter.lib

12
Jupiter/ArrayList.h

@ -52,6 +52,13 @@ namespace Jupiter
*/
T *remove(size_t index);
/**
* @brief Removes the last element in the list, and returns the data removed.
*
* @return Data removed.
*/
T *pop();
/**
* @brief Adds data to the list at a specified index.
*
@ -182,6 +189,11 @@ template<typename T> T *Jupiter::ArrayList<T>::remove(size_t index)
return r;
}
template<typename T> T *Jupiter::ArrayList<T>::pop()
{
return Jupiter::ArrayList<T>::data[--Jupiter::List<T>::length];
}
template<typename T> void Jupiter::ArrayList<T>::add(T *ndata, size_t index)
{
if (Jupiter::List<T>::length == Jupiter::ArrayList<T>::dataSize) Jupiter::ArrayList<T>::expandArray();

19
Jupiter/IRC_Client.cpp

@ -115,8 +115,15 @@ struct Jupiter::IRC::Client::Channel::User::Data
{
Jupiter::IRC::Client::User *user;
Jupiter::StringS prefixes;
~Data();
};
Jupiter::IRC::Client::Channel::User::Data::~Data()
{
--Jupiter::IRC::Client::Channel::User::Data::user->data_->channelCount;
}
struct Jupiter::IRC::Client::Channel::Data
{
Jupiter::StringS channel;
@ -1054,7 +1061,7 @@ int Jupiter::IRC::Client::primaryHandler()
this->OnPart(chan, nick, reason);
for (i = Jupiter::plugins->size() - 1; i >= 0; i--) Jupiter::plugins->get(i)->OnPart(this, chan, nick, reason);
if (nick.equalsi(Jupiter::IRC::Client::data_->nickname)) Jupiter::IRC::Client::data_->delChannel(chan);
if (user->getChannelCount() == 0) Jupiter::IRC::Client::data_->users.remove(userIndex);
if (user->getChannelCount() == 0) delete Jupiter::IRC::Client::data_->users.remove(userIndex);
}
}
}
@ -1090,7 +1097,7 @@ int Jupiter::IRC::Client::primaryHandler()
Jupiter::IRC::Client::data_->delChannel(chan);
if (Jupiter::IRC::Client::data_->joinOnKick) Jupiter::IRC::Client::joinChannel(chan);
}
if (user->getChannelCount() == 0) Jupiter::IRC::Client::data_->users.remove(userIndex);
if (user->getChannelCount() == 0) delete Jupiter::IRC::Client::data_->users.remove(userIndex);
}
}
}
@ -1110,7 +1117,7 @@ int Jupiter::IRC::Client::primaryHandler()
Jupiter::IRC::Client::data_->channels.get(i)->delUser(nick);
this->OnQuit(nick, message);
for (i = 0; i < Jupiter::plugins->size(); i++) Jupiter::plugins->get(i)->OnQuit(this, nick, message);
if (user->getChannelCount() == 0) Jupiter::IRC::Client::data_->users.remove(userIndex);
if (user->getChannelCount() == 0) delete Jupiter::IRC::Client::data_->users.remove(userIndex);
}
}
else if (w2.equalsi("INVITE"))
@ -1617,11 +1624,7 @@ void Jupiter::IRC::Client::Channel::delUser(const Jupiter::ReadableString &nickn
void Jupiter::IRC::Client::Channel::delUser(size_t index)
{
if (index < Jupiter::IRC::Client::Channel::data_->users.size())
{
Jupiter::IRC::Client::Channel::User *user = Jupiter::IRC::Client::Channel::data_->users.remove(index);
user->data_->user->data_->channelCount--;
delete user;
}
delete Jupiter::IRC::Client::Channel::data_->users.remove(index);
}
void Jupiter::IRC::Client::Channel::addUserPrefix(size_t index, char prefix)

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save