root@bu-cs.UUCP (Barry Shein) (03/17/85)
Ron, [note, I am not flaming at you, just a ref to your comment] You say what galls you is the unnecessary padding on the VAX C, what galls me more is the otherwise simple programs that won't re-compile on our 3B5 cuz people played foot-loose and fancy-free with the VAX's liberalness with alignment. Typical bad idiom: struct string { short int length ; char *data ; } ; /* Obvious error checking omitted for brevity */ /* allocate space for a BCPL style string w/o calling malloc() too often */ struct string * newstring(cp) char *cp ; { static char *mypage = NULL ; struct string *sp ; if(mypage == NULL) mypage = (char *) malloc(LOTSAMEM) ; sp = (string *) mypage ; sp->length = strlen(cp) ; strcpy(sp->data,cp) ; mypage += sizeof(sp->length) + sp->length ; return(sp) ; } Looks wonderful, all full of fuzzy warm casts and types. Except an odd length string leaves the next length on an odd boundary. Sigh....[yes, the 3B5 then dies on the odd word ref] -Barry Shein, Boston University P.S. Yes I know how to fix this by padding the sp->length to an even size. Just tired of doing it, and even that is not safe for all machines.
ron@brl-tgr.ARPA (Ron Natalie <ron>) (03/17/85)
> You say what galls you is the unnecessary padding on the VAX C, > what galls me more is the otherwise simple programs that won't > re-compile on our 3B5 cuz people played foot-loose and fancy-free > with the VAX's liberalness with alignment. Typical bad idiom: > > P.S. Yes I know how to fix this by padding the sp->length to an even size. > Just tired of doing it, and even that is not safe for all machines. Congratulations, your example has nothing whatsoever to do with what I was talking about.