Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!alverson From: alverson@decwrl.dec.com (Robert Alverson) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <286@bacchus.DEC.COM> Date: 18 Feb 88 05:13:23 GMT References: <2635@calmasd.GE.COM> <28200092@ccvaxa> <496@ecrcvax.UUCP> <3001@bloom-beacon.MIT.EDU> Reply-To: alverson@decwrl.UUCP (Robert Alverson) Organization: Digital Equipment Corporation Lines: 21 In article <3001@bloom-beacon.MIT.EDU> jfc@athena.mit.edu (John F Carr) writes: > > (&(s.a) - &(s.b)) == 1 it is making an unsupported assumption. Can >someone post an example of a program which is portable and depends on >the K&R rule quoted above? How about this: typedef struct VarStr_str { int len; char str[1]; } VarStr; VarStr *MakStr(s) char *s; { VarStr *p = malloc(sizeof(VarStr) + strlen(s)); strcpy(p->str, s); return p; } This is a commonly used technique to avoid another memory indirection when accessing the variable data in the structure. Bob