ChannelizerBase::~ChannelizerBase()
{
	int i;

	releaseFilters();
	free_fft(fftHandle);

	for (i = 0; i < mChanM; i++) {
		cxvec_free(filtInputs[i]);
		cxvec_free(filtOutputs[i]);
		cxvec_free(history[i]);
	}

	free(filtInputs);
	free(filtOutputs);
	free(history);
}
void ChannelizerBase::releaseFilters()
{
	for (int i = 0; i < mChanM; i++) {
		cxvec_free(subFilters[i]);
	}

	free(subFilters);
}
void RadioInterface::close()
{
	int i;

	cxvec_free(highRateTxBuf);
	cxvec_free(highRateRxBuf);

	/* Don't deallocate class member buffers */
	for (i = 0; i < mChanM; i ++) {
		lowRateRxBufs[i]->buf = NULL;
		lowRateTxBufs[i]->buf = NULL;

		cxvec_free(lowRateRxBufs[i]);
		cxvec_free(lowRateTxBufs[i]);
	}

	delete chan;
	delete synth;
}
/*! \brief Reverse a complex vector
 *  \param[in] in Complex input vector
 *  \param[out] out Complex output vector pointers
 */
int cxvec_rvrs(struct cxvec *in, struct cxvec *out)
{
	int i;
	struct cxvec *rev = cxvec_alloc(in->len, 0, NULL, 0);

	for (i = 0; i < in->len; i++)
		rev->data[i] = in->data[in->len - 1 - i];

	memcpy(out->data, rev->data, in->len * sizeof(float complex));

	cxvec_free(rev);

	return 0;
}