Re: [PATCH 2/2] alloca.3: rewrite NOTES

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Ahelenia!

On 8/24/21 12:33 PM, Alejandro Colomar (man-pages) wrote:

And apart from what Michael (and Branden) already said, I have one question that has not been treated before it seems:

AFAIK, VLAs are 100% equivalent to alloca() (except for the obvious syntax differences).  And considering the VLA syntax is much nicer than alloca(), and is in the standard (IIRC, C99 added VLAs, and C11 declared them optional), what about adding a NOTES subsection that recommends (or at least mentions) VLAs?

And they both share the problem of smashing the stack if you try to allocate an array to big (and none of them has a way to check if it will happen, AFAIK).

Now that I think, there's a slight difference, of course: VLAs live in their block scope, while alloca() lives in the function scope, allowing to embed it in a macro such as strdupa().

But maybe still worth mentioning VLAs in alloca(3).

Cheers,

Alex


--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux