- predecessor_table_ = nullptr;
- cost_table_ = nullptr;
- link_table_ = nullptr;
-}
-
-FloydZone::~FloydZone()
-{
- if (link_table_ == nullptr) // Dealing with a parse error in the file?
- return;
- unsigned int table_size = get_table_size();
- /* Delete link_table */
- for (unsigned int i = 0; i < table_size; i++)
- for (unsigned int j = 0; j < table_size; j++)
- delete TO_FLOYD_LINK(i, j);
- delete[] link_table_;
-
- delete[] predecessor_table_;
- delete[] cost_table_;
+ if (link_table_.size() != table_size) {
+ /* Resize and initialize Cost, Predecessor and Link tables */
+ cost_table_.resize(table_size);
+ link_table_.resize(table_size);
+ predecessor_table_.resize(table_size);
+ for (auto& cost : cost_table_)
+ cost.resize(table_size, ULONG_MAX); /* link cost from host to host */
+ for (auto& link : link_table_)
+ link.resize(table_size); /* actual link between src and dst */
+ for (auto& predecessor : predecessor_table_)
+ predecessor.resize(table_size, -1); /* predecessor host numbers */
+ }