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

#include <train_lattice_node.h>

// method: grow_lat_cc
//
// arguments: none
//
// return: a logical_1 indicating success
//
// this method grows the number of empty lattice nodes by the lattice node
// grow size
//
logical_1 Train_Memory_manager::grow_lat_cc() {

  // create new empty lattice nodes
  //
  Train_Link_node* lnd = (Train_Link_node*)NULL;
  
  // insert the lattice nodes in a list
  //
  for (int_4 i = 0; i < lat_grow_size_d; i++) {
    Train_Lattice_node* latn = new Train_Lattice_node;
    lnd = new_node_cc();
    lnd->set_item_cc((void_p)latn);
    if ((i == (int_4)0) && (lat_count_d == (int_4)0)) {
      lat_list_d = lnd;
    }
    else {
      lat_list_d->insert_cc(lnd);
    }
    latn++;
  }
  
  // update the count of free lats
  //
  lat_count_d += lat_grow_size_d;

  // exit gracefully
  //
  return ISIP_TRUE;
}
