C99 Features

Nathaniel McCallum npmccallum at redhat.com
Thu Jun 18 00:24:04 EDT 2015


On Thu, 2015-06-18 at 01:13 +0000, Danilo Almeida wrote:
> <quote from="Nico">
> Both are fine when the sizes are naturally limited to small sizes, 
> but this requires more review effort.  Alternatively one could have a 
> macro to guard against unsafe array sizes.  I'd rather VLAs and 
> alloca() were frowned upon (though not forbidden).
> </quote>
> 
> I am not sure how such a macro would work.
> 
> Otherwise, I mostly agree with Nico, except that I am not comfortable 
> with the "though not forbidden" part.  Nathaniel, do you have any 
> performance numbers would help the case for the extra effort (and 
> potential risk)?

Well, take common inner-function heap allocations and turn them into
stack allocations. That is a significant performance gain.

VLAs make perfect sense for operations like fx_cf2 where you need to
mix two keys together using intermediary buffers. If you validate that
the input keys are valid types then you know that the buffer for that
type will be a sensible size to put on the stack. This eliminates two
unnecessary heap allocations.

Nathaniel


More information about the krbdev mailing list