【发布时间】:2011-10-24 13:07:38
【问题描述】:
我确实意识到有一些“检测到 glibc”的帖子,但如果您能为此提出解决方案,我将不胜感激:
*** glibc detected *** ./a.out: double free or corruption (top): 0x08901d70 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6c501)[0x17c501]
/lib/libc.so.6(+0x6dd70)[0x17dd70]
/lib/libc.so.6(cfree+0x6d)[0x180e5d]
/lib/libc.so.6(fclose+0x14a)[0x16c81a]
./a.out[0x8048998]
/lib/libpthread.so.0(+0x5cc9)[0xc1fcc9]
/lib/libc.so.6(clone+0x5e)[0x1e069e]
======= Memory map: ========
这似乎发生在我尝试释放二叉搜索树时:
void freetree(BNODEPTR *root)
{
if(root!=NULL)
{
freetree(root->left);
freetree(root->right);
free(root);
}
}
结构的类型定义为 BNODEPTR
struct bnode{
int info;
int count;
struct bnode* left;
struct bnode* right;
};
我正在使用 freetree(root) 从 main() 调用函数。
这棵树似乎被正确地实现了,因为中序遍历产生了一个排序的输出。
整个代码在:
【问题讨论】:
标签: c data-structures tree binary-search-tree