// file: circular_buffer/cb_alloc_0.cc
//

// isip include files
//
#include "CircularBuffer.h"

// method: allocation
//
// arguments: 
//
//  int dim: (input) dimensions of circular buffer
//  int num_elements: (input) maximum size of circular buffer
//
// return: none
//
// this method allocates memory for circular buffer.
//
void Circular_buffer::allocate_cc(int dim, int num_elements) {

  // check if a buffer already exists
  //
  if (buf_d != (float_8**)NULL) {
    
    for (int i = 0; i < dim_d; i++) {
      delete [] buf_d[i];
    }
    delete [] buf_d;
    delete [] idx_d;
    delete [] num_d;
  }

  // allocate a buffer
  //
  size_d = num_elements;
  dim_d = dim;
  
  buf_d = new float_8*[dim_d];
  idx_d = new int[dim_d];
  num_d = new int[dim_d];
  for (int i = 0; i < dim_d; i++) {
    buf_d[i] = new float_8[size_d];
    idx_d[i] = -1;
    num_d[i] = 0;
  }

  // exit gracefully
  //
}
