Very simple code:
signed int **ifftResults = (signed int **)malloc(sizeof(signed int *) * recordsPerBuffer);
for (int i=0; i < recordsPerBuffer; i++)
{
ifftResults[i] = (signed int*)malloc(sizeof(signed int) * fftLength);
}
Then later:
for (int i=0; i < recordsPerBuffer; i++)
{
free(ifftResults[i]);
}
free(ifftResults);
When I comment these lines out – no memory leak. When they are present – memory leak. Hopefully I just need another pair of eyes, cause I cannot for the life of me see what’s wrong.
The code presented as I’m writing this doesn’t seem to be sufficient to answer the question of “why”.
However, since you’re using C++ you can make sure that there’s no memory leak by using
std::vector.Like so:
Another way to implement a matrix is like
and then compute the index for given (x,y).
Cheers & hth.,