// file: tr_mm_grow_4.cc
//
 
// isip include files
//
#include "train_memory_manager.h"
#include "train_memory_manager_constants.h"

#include <train_hash_cell.h>

// method: grow_hash_cc
//
// arguments: none
//
// return: a logical_1 indicating success
//
// this method grows the number of empty hash table cells by the hash
// table cell grow size
//
logical_1 Train_Memory_manager::grow_hash_cc() {
  
  // create new empty hash table cells
  //
  Train_Link_node* lnd = (Train_Link_node*)NULL;
  
  // insert the hash table cells in a list
  //
  for (int_4 i = 0; i < hash_grow_size_d; i++) {
    Train_Hash_cell* hcells = new Train_Hash_cell;
    lnd = new_node_cc();
    lnd->set_item_cc((void_p)hcells);
    if ((i == (int_4)0) && (hash_count_d == (int_4)0)) {
      hash_list_d = lnd;
    }
    else {
      hash_list_d->insert_cc(lnd);
    }
    hcells++;
  }
  
  // update the count of free hashs
  //
  hash_count_d += hash_grow_size_d;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
