alloca 函数摘自APUE.3E

alloca Function

One additional function is also worth mentioning. The function alloca has the same calling sequence as malloc; however, instead of allocating memory from the heap, the memory is allocated from the stack frame of the current function. The advantage is that we don't have to free the space; it goes away automatically when the function returns. The alloca function increases the size of the stack frame. The disadvantage is that some systems can't support alloca, if it's impossible to increase the size of the stack frame after the function has been called. Nevertheless, many software packages use it, and implementations exist for a wide variety of systems

--核心的意思是 alloca和malloc不同的是从栈(stack)中分配空间而不是堆(heap);它的好处是释放它分配的空间不是必需的。同时它也增大了程序的栈空间,但是有一点需要说明的不是所有的系统都支持alloca。

 

猜你喜欢

转载自www.cnblogs.com/shineshe/p/9767290.html