Why is the use of alloca() not considered good practice?

前端 未结 22 2458
甜味超标
甜味超标 2020-11-22 03:00

alloca() allocates memory on the stack rather than on the heap, as in the case of malloc(). So, when I return from the routine the memory is freed.

22条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 03:26

    One issue is that it isn't standard, although it's widely supported. Other things being equal, I'd always use a standard function rather than a common compiler extension.

提交回复
热议问题