Re: [dev] [style] variable declaration locations and varriable length arrays vs malloc

From: Evan Gates <evan.gates_AT_gmail.com>
Date: Mon, 2 Mar 2015 16:30:17 -0800

Also how strict should the rule be? Is calling functions to define
variables when declaring them considered mixing declarations and code?
i.e. is this allowed?

size_t len = strlen(s);
char *buf = emalloc(len + 1);

etc. etc.


On Mon, Mar 2, 2015 at 3:43 PM, Markus Teich <markus.teich_AT_stusta.mhn.de> wrote:
> Heyho,
>
> a suckless piece of code, where this is used would be the manage() function of
> tabbed.c. I don't mind it to declare variables in inner blocks, so it is clear
> to the reader that this variable is only intended to be used inside this block
> and not only the mighty compiler is able to magically see, that the scope can be
> optimized.
>
> --Markus
>

I agree that declaring variables only in the scope they are used can
make the code clearer and I do that as well, although that may have to
change depending on the prevailing style in sbase.

-emg
Received on Tue Mar 03 2015 - 01:30:17 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 03 2015 - 01:36:07 CET