// file: dec_clean_3.cc
//

// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"
 
// method: clean_instances_cc
//
// arguments: none
//
// return: logical_1 indicating status
//
// this method cleans up all the instances in the instance table
//
logical_1 Decoder::clean_instances_cc() {

  // dummy variables
  //
  Instance* inst = (Instance*)NULL;
  Hash_cell** hcells = (Hash_cell**)NULL;
  Hash_cell* hcell = (Hash_cell*)NULL;
  int_4 hsize = (int_4)0;
  
  // deallocate the instance hash-table
  //
  hcells = inst_table_d->get_cells_cc();
  hsize = inst_table_d->get_size_cc();
  for (int_4 k = 0; k < hsize; k++) {
    for (Hash_cell* cell = hcells[k]; cell != (Hash_cell*)NULL;
	 cell = hcell) {
      hcell = cell->get_next_cc();
      inst = (Instance*)(cell->get_item_cc());
      manager_d->delete_cc(inst);
      manager_d->delete_cc(cell);
    }
    hcells[k] = (Hash_cell*)NULL;
  }
  delete inst_table_d;    
  inst_table_d = (Hash_table*)NULL;

  // exit gracefully
  //
  return ISIP_TRUE;
}
  
