// file: dec_update_0.cc
//

// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"

// method: update_history_cc
//
// arguments: none
//
// return: a logical_1 to indicate status
//
// this method loops through all history nodes and deletes the
// inactive histories
//
logical_1 Decoder::update_history_cc() {

  // dummy variables
  //
  History* hist = (History*)NULL;
  Link_node* lnd = (Link_node*)NULL;
  
  // loop over all active histories
  //
  for (Link_node* nd = history_list_d->get_head_cc();
       nd != (Link_node*)NULL; nd = lnd) {
    
    // advance node pointer
    //
    lnd = nd->get_next_cc();
    
    // get the history
    //
    hist = (History*)(nd->get_item_cc());
    
    // if this is marked inactive
    //
    if (hist->get_ref_count_cc() == (int_4)0) {
      
      // delete this history node
      //
      manager_d->delete_cc(hist);
      history_list_d->remove_cc(nd);
    }
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
