我无法弄明白。为什么我收到错误
malloc: *** error for object 0x7fd812403a80: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
以下是代码的片段。如果我注释掉方法'pre_compute_nCr'的函数调用,那么代码按预期工作。但是,它唯一的调用函数'pre_compute_nCr',它会弹出上面提到的错误。在代码中,'binom_obj(i,j)'返回'i choose k'的值
void pre_compute_nCr (int n, std::vector<std::vector<uint64_t>>& n_chos_k) {
n_chos_k[0].push_back(0);
for (int i = 1; i < n; ++i) n_chos_k[i].resize(i, 0);
jaz::Binom<int> binom_obj;
for (uint64_t i = 1; i < n; ++i) {
for (uint64_t j = 0; j <= i; ++j) {
n_chos_k[i][j] = binom_obj(i, j);
} // for j
} // for i
}
int dynamicProgramming(int n, XX xx_obj) {
std::vector<std::vector<uint64_t>> n_chos_k;
n_chos_k.resize(n);
pre_compute_nCr(n, n_chos_k);
return 0;
}