several bugfixes, including some memory management

This commit is contained in:
Arnout Engelen
2004-09-14 16:14:23 +00:00
parent a695b7db2a
commit cf2f473cd1
7 changed files with 82 additions and 51 deletions

View File

@@ -43,7 +43,8 @@ bpf_u_int32 PackList::sumanddel (timeval t)
while (current != NULL)
{
if (current->val->isOlderThan(t))
//std::cout << "Comparing " << current->val->time.tv_sec << " <= " << t.tv_sec - PERIOD << endl;
if (current->val->time.tv_sec <= t.tv_sec - PERIOD)
{
if (current == content)
content = NULL;
@@ -83,11 +84,36 @@ Connection::~Connection ()
{
if (DEBUG)
std::cout << "Deleting connection" << std::endl;
delete refpacket;
/* refpacket is a pointer to one of the packets in the lists,
* so not deleted */
//delete refpacket;
if (sent_packets != NULL)
delete sent_packets;
if (recv_packets != NULL)
delete recv_packets;
ConnList * curr_conn = connections;
ConnList * prev_conn = NULL;
while (curr_conn != NULL)
{
if (curr_conn->val == this)
{
ConnList * todelete = curr_conn;
curr_conn = curr_conn->next;
if (prev_conn == NULL)
{
connections = curr_conn;
} else {
prev_conn->next = curr_conn;
}
delete (todelete);
}
else
{
prev_conn = curr_conn;
curr_conn = curr_conn->next;
}
}
}
void Connection::add (Packet * packet)