Commit dfe2bfbe authored by Colby J Green's avatar Colby J Green
Browse files

fix valgrind errors

parent 47791d0e
......@@ -8,6 +8,7 @@ Signal::Signal(int n)
Signal::~Signal()
{
delete[] this->m_buffer;
}
double &Signal::operator[](int n)
......@@ -32,7 +33,7 @@ Signal Signal::convolve(Signal &h)
double sum = 0.0;
for (int xI = 0, hI = n; xI < xN; ++xI, --hI) {
if (0 <= hI && hI <= hN)
if (0 <= hI && hI < hN)
sum += x[xI] * h[hI];
}
......
......@@ -8,7 +8,7 @@ int main(int argc, char *argv[])
Signal h(size);
// let both be rect filters
for (int i = 0; i <= x.size(); ++i) x[i] = 1.0;
for (int i = 0; i < x.size(); ++i) x[i] = 1.0;
for (int i = 0; i < h.size(); ++i) h[i] = 1.0;
Signal y = x.convolve(h);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment