This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

28335,malloc,死循环

我在一个28335的工程当中调用了一个一段malloc指令:malloc(10)

运行以后程序便进入到这个函数的:

while (current != LIMIT && -current->packet_size < allocsize)
{
prev = current;
current = current->next_free;
}

在循环当中跳不出来了,在debug的模式下检查发现是current->next_free指向了自己

这个是我的调用有错误吗?

  • .stack分配的内存如下:

    .sysmem      .esysmem 分配地址如下

    .cinit  分配地址如下:

  • 有可能是heap size分配太小了,如果heap分配的空间太小,分配过程中会产生溢出。
    可以在Project -> Properties -> Build ->C2000 Linker -> Basic Options -> Heap size for ...中修改加大一下分配的地址空间