Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
struct big {
    unsigned long long member_1; /* typically 8 bytes */
    unsigned long long member_2; /* typically 8 bytes */
    unsigned long long member_3; /* typically 8 bytes */
    int member_4; /* typically 4 bytes */
    int member_5; /* typically 4 bytes */
};
/* ... */
size_t skip_member = sizeof(unsigned long long);
struct big *s = malloc(sizeof(struct big));
if (!s) {
   /* Handle malloc() error */
}

memset(s + skip_member, 0, sizeof (struct big) - skip_member);
/* ... */
free(s);

...