为什么你必须释放 malloc 分配的内存而不是你分配的内存来表示你声明的函数,如 int 或 bool?

Why do you have to free memory allocated by malloc but not the memory that you allocate to say a function you declared like int or bool?

正如标题所说,您释放使用 malloc 分配的内存,但从未释放分配给整数等变量的内存的原因是什么?

编译器只需将堆栈指针移动到变量所需的space,即可为堆栈上的局部变量分配space。 return前,堆栈恢复

当您调用 malloc 时,内存 space 被分配到所谓的 中。 被管理以保持分配的块,直到调用freerealloc