当我尝试在代码中为矩阵释放已分配的内存时,我遇到了问题。 我正在使用这个功能:
void free_matrix(float **m, int row)
{
for( int i=0; i<row; i++ )
{
free( m[i]);
}
free(m);
}
但我不知道为什么它不起作用我得到了这个错误:
Windows has triggered a breakpoint in mycode.exe.
This may be due to a corruption of the heap, which indicates a bug in mycode.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while mycode.exe has focus.
答案 0 :(得分:0)
最有可能的是,您正在释放尚未分配的内存。检查分配内存的代码,或者更好的是,发布给我们看。确保您只在有效指针上免费拨打电话。另外,请确保“新”与“免费”不匹配。