2 #include "Hash_Table.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_Memory.h"
5 #include "ace/OS_NS_string.h"
7 Hash_Table::Hash_Table ()
10 hash_table_size (HASH_TABLE_SIZE
)
12 ACE_NEW (this->hash_table
,
13 Protocol_Record
*[this->hash_table_size
]);
14 ACE_OS::memset (this->hash_table
,
16 this->hash_table_size
* sizeof *this->hash_table
);
19 // Iterate through the hash table returning one node at a time...
22 Hash_Table::get_next_entry ()
24 // Reset the iterator if we are starting from the beginning.
26 if (this->current_index
== -1)
27 this->current_index
= 0;
29 if (this->current_ptr
== 0)
31 for (; this->current_index
< this->hash_table_size
; this->current_index
++)
32 if (this->hash_table
[this->current_index
] != 0)
34 Protocol_Record
*prp
= this->hash_table
[this->current_index
++];
35 this->current_ptr
= prp
->next_
;
39 this->current_index
= -1;
44 Protocol_Record
*prp
= this->current_ptr
;
45 this->current_ptr
= this->current_ptr
->next_
;
51 Hash_Table::get_each_entry ()
53 return this->get_next_entry ();
56 // Frees up all the dynamic memory in the hash table.
58 Hash_Table::~Hash_Table ()
60 if (Options::get_opt (Options::DEBUGGING
))
62 "disposing Hash_Table\n"));
64 for (int i
= 0; i
< this->hash_table_size
; i
++)
65 for (Protocol_Record
*prp
= this->hash_table
[i
];