This is a matter of balance and complexity. If most of the members in the structure never access the while loop, initialization is clearly redundant ... BUT THAT, why are they sitting together inside the structure? What was their original purpose? In this case, the code itself is more complex than necessary, although unoccupied data in C is, of course, less confusing than never-executable code.
If OTOH the main part of the structure elements is used in the while loop, then adding a simple zero assignment to each of them will not hurt much, because each subsequent operation on this member more or less mitigates the impact on 1 / n initialization performance.
What I see as harmful to the maintenance of the code is that the init function itself needs to know the structure, which means that you scatter the information in more places than necessary. IIRC C allows memset attributes to be structured (touch the structure as an unsigned char vector), and the participants will really come out 0 ==> if this is a blatant right, then I am very sorry and someone can break the printed version of all the standards above my head.
slartibartfast
source share