Reply to post:

Linus Torvalds fires off angry 'compiler-masturbation' rant

Anonymous Coward
Anonymous Coward

int init_structure(struct my_structure** s)

{

enum { eAlign = 7 } ;

size_t aligned_size, total_space;

char *base;

aligned_size = ((eAlign+sizeof(struct my_structure)) &(~eAlign));

total_space = aligned_size + sizeof(struct my_substructure);

errno = 0;

base = calloc(total_space,sizeof(*base));

if(!base)

return errno;

*s = (void *)base;

*s->substructure = (void *)(base + aligned_size);

return 0;

}

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon