Code review comment for lp://staging/~smspillaz/compiz-core/fix_894688

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The main reason (other than stylistic and religious) for not using memcmp on structs is because structs are often not perfectly aligned and so contain padding bytes. The padding bytes are uninitialized, unpredictable and inaccessible unless you also guarantee each struct has first been memset(&s,0,sizeof(s)).

In general, memcmp is highly optimized for the architecture and is in fact faster than a bespoke operator. However you can't use memcmp with structs unless you guarantee they're always fully initialized with memset to the full sizeof(yourstruct).

« Back to merge proposal