Evan Gates writes:
> Declaring variables at the top of a block, as opposed to top of the
> function has a few uses, but the most useful (in my limited
> experience) is combining it with C99's variable length arrays to
> create buffers without calls to malloc/free. For example:
> 
> while ((d = readdir(dp))) {
>     char buf[strlen(path) + strlen(d->d_name) + 1];
>     ....
> }

VLAs are a fundamentally broken feature because they do not allow any
error checking. alloca() is the same.

-- 
Anthony J. Bentley

Reply via email to