memory exception using _aligned_malloc and _aligned_free
Code:
//i am allocating cache-aligned buffers using:
Matrix::Matrix(const unsigned int _rows, const unsigned int _columns):
//...
data((double*)_aligned_malloc(sizeof(double)*(rows*columns+1),32))
//...
{}
//and freeing them like so:
Matrix::~Matrix()
{
if(data)_aligned_free(data);
data=0;
}
data is aligned on 0x20 boundaries, just like i wanted, but problem is, i'm getting a heap corruption exception inside _aligned_free at location 0x10 LESS than where my buffer starts.
what gives? am i doing something wrong or is this something evil about aligned malloc/free?