我制作了一些使用ncurses来使用窗口(?)的程序。
有奇怪的问题!! (我使用PUTTY)
如果我们更改窗口大小,deleteTree()工作不正常。 但是如果我们保持窗口大小,deleteTree()运行良好!!
deleteTree()的功能是
MAX_CHILD = 100
enum DAY {MON, TUE, WED, THU, FRI, SAT, SUN};
enum TREE_TYPE {HEADER,DAY,PLACE,ROOM};
typedef struct _tree {
enum TREE_TYPE type;
union _info info;
struct _tree* link[MAX_CHILD];
} tree;
typedef tree* tNode;
tNode tRoot;
void deleteTree(tNode* twalk)
{
int i;
if (*twalk == NULL)
return;
for (i=0;i < MAX_CHILD;i++)
{
if ((*twalk)->link[i] != NULL){
deleteTree(&(*twalk)->link[i]);
(*twalk)->link[i] = NULL;
}else break;
}
free(*twalk);
*twalk = NULL;
}
和
void deleteTree(tNode twalk)
{
int i;
if (twalk == NULL)
return;
for (i=0;twalk->link[i]!=NULL;i++)
{
deleteTree(twalk->link[i]);
free(twalk->link[i]);
twalk->link[i] = NULL;
}
if (twalk == tRoot)
{
if (twalk != NULL)
free(twalk);
tRoot = NULL;
}
}
如果更改窗口大小,它们都不起作用。错误消息是细分falut(核心转储)。
我认为这个错误意味着当更改窗口大小改变内存的位置时。 如何解决这个问题......?