// file: tr_mm_new_0.cc
//
 
// isip include files
//
#include "train_memory_manager.h"
#include "train_memory_manager_constants.h"
 
// method: new_node_cc
//
// arguments: none
//
// return: a Train_Link_node* pointer to a new link list node
//
// this method outputs a new empty link list node, and creates them
// whenever necessary
//
Train_Link_node* Train_Memory_manager::new_node_cc() {

  // dummy variables
  //
  Train_Link_node* node = (Train_Link_node*)NULL;

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

  // get a node off the list
  //
  node = node_list_d;
  node_list_d = node_list_d->get_next_cc();

  // adjust params
  //
  node->set_next_cc((Train_Link_node*)NULL);
  node->set_prev_cc((Train_Link_node*)NULL);
  
  // decrement free node count
  //
  node_count_d --;
  
  // return the node and exit gracefully
  //
  return node;
}
