// file: filter/filt_set_1.cc
//

// system include files
//
#include <strings.h>
#include <memory.h>

// isip include files
//
#include "filter.h"
#include "filter_constants.h"

// method: allocate_cc
//
// arguments:
//  int_4 width_d: (input) length of filter to create
//
// return: a logical_1 indicating status
//
logical_1 Filter::allocate_cc(int_4 width_a) {

  if (width_a > width_d) {

    // delete the data, if necessary
    //
    if (data_d != (float_8*)NULL) {
      delete [] data_d;
      data_d = (float_8*)NULL;
    }
    
    // allocate the data
    //
    data_d = new float_8[width_a];
  }
  else {

    // use pre-existing memory
    //
    memset(data_d, 0, sizeof(float_8)*width_a);
  }
   
  // set the filter width
  //
  width_d = width_a;

  // exit gracefully
  //
  return ISIP_TRUE;
}
