On 26/07/12 22:05, Joerg Sonnenberger wrote:
[...]
> It's a popular C&P error. Don't know how many instances of it I fixed in
> various OSS projects...

FWIW, there's a little-known wrinkle in the C spec that states that
while *un*initialised auto variables have undefined value, and
*initialised* auto variables have the specified value, *partially*
initialised auto variables are initialised as if they were globals. i.e.
filled with zeroes.

char buffer[80] = {0};

...is totally legal and avoids the need to call memset. It can be
faster, too.

See:

http://stackoverflow.com/questions/10828294/c-and-c-partial-initialization-of-automatic-structure


-- 
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to