Memset or memberwise zero
- For sure it’s premature optimization, thus performance arguments are omitted.
- Thus it’s a question of style.
- memset
- ensures whole struct is zeroed, however hides initialization of individual members (though they are usually meant to be initially zero)
- memberwise
- explicitly indicates what we are doing with the structure
- prone to leaving out some members -> hard to hunt non-deterministic bugs
- not robust against ABI changes
- conclusion:
Prefer memset.- Use calloc.
- memset