自己定义了链表,初始化时malloc了300个单元,每个单元20字节,总共6000个字节。M451有32K内存
为什么我初始化到260个链表节点时出错。
void creatqueue()
{
UINT16 i = 0;
WINDOW_INFO *newwindow;
newwindow = (WINDOW_INFO *)malloc(sizeof(WINDOW_INFO));
newwindow->windowhd = 1;
newwindow->prev = NULL;
newwindow->next = NULL;
window_unused.first = newwindow;
window_unused.last = newwindow;
window_unused.window_sum = 1;
for(i = 2; i <= MAXWINDOW;i++)
{
queue_addNode(i);
if(i >= 266)
cntd--;//这之后出错了
if(i >= 270)
cntd--;
}
}
void queue_addNode(int windowhd)
{
WINDOW_INFO *newwindo,*tempwindow;
newwindo = (WINDOW_INFO *)malloc(sizeof(WINDOW_INFO));
newwindo->windowhd = windowhd;
tempwindow = window_unused.first;
while(tempwindow != window_unused.last)//查找到最后一个
{
tempwindow = tempwindow->next;
}
window_unused.window_sum++;
tempwindow->next = newwindo;
newwindo->prev = tempwindow;
window_unused.last = newwindow;
}
代码不在操作系统里跑可以的
|