// file: mm_new_6.cc
//
 
// isip include files
//
#include "memory_manager.h"
#include "memory_manager_constants.h"

#include <history.h>

// method: new_hist_cc
//
// arguments: none
//
// return: a History* pointer to a new history node
//
// this method outputs a new empty history node, and creates them whenever
// necessary
//
History* Memory_manager::new_hist_cc() {

  // if there are no free history nodes available, create a few
  //
  if (hist_count_d == (int_4)0) {
    grow_hist_cc();
  }

  // get a history node off the list
  //
  Link_node* lnd = hist_list_d;
  hist_list_d = hist_list_d->get_next_cc();

  // adjust params
  //
  lnd->set_next_cc((Link_node*)NULL);

  if (hist_list_d != (Link_node*)NULL) {
    hist_list_d->set_prev_cc((Link_node*)NULL);
  }

  // get the hist node here
  //
  History* hist = (History*)(lnd->get_item_cc());

  // return the link node to the free node list
  //
  delete_cc(lnd);

  // decrement free hist node count
  //
  hist_count_d--;
  
  // return the hist node and exit gracefully
  //
  return hist;
}
