subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Foad <julianf...@btopenworld.com>
Subject Re: Review of sizeof usage
Date Thu, 13 Aug 2015 15:44:24 GMT
FWIW, I too have come to prefer the variable-based form, for
readability reasons. One reason is that it is easier to quickly
recognize and verify the idiom when the redundancy is in the form of
two identical names close together:

svn_my_type_t *my_var;
[...]
foo(my_var, sizeof(*my_var));  <== 'my_var' twice

than when the nearby pairing uses two different names and the
repetition of the type name is widely separated:

svn_my_type_t *my_var;
[...]
foo(my_var, sizeof(svn_my_type_t));

especially when the declaration was separate from the statement that uses it.

Another reason is that the variable name is usually shorter, the
entire statement often fitting on one line, whereas the type name is
usually a public, user-defined type (or pointer to such) with a longer
name.

- Julian

Mime
View raw message