Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!novavax!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.lang.c Subject: Re: hardcoded constants Message-ID: <283@twwells.uucp> Date: 29 Dec 88 06:54:36 GMT References: <1988Dec8.173158.11839@utzoo.uucp> <846@starfish.Convergent.COM> <9134@smoke.BRL.MIL> <1988Dec13.172306.16195@utzoo.uucp> <5146 <2636@m2-net.UUCP> <1988Dec26.021757.15813@ziebmef.uucp> Reply-To: bill@twwells.UUCP (T. William Wells) Organization: None, Ft. Lauderdale Lines: 26 Summary: Expires: Sender: Followup-To: Distribution: Keywords: In article <1988Dec26.021757.15813@ziebmef.uucp> cks@ziebmef.UUCP (Chris Siebenmann) writes: : For true safety, I'd write this as : : foo = malloc(Catspace(s,t)*sizeof(char) + sizeof('/')); : : (or redefine Catspace() to do this itself, depending on whether it : returns a character or byte count), just in case someone produces a : compiler where characters aren't single bytes. Characters are required to be single bytes. Note that this doesn't prevent the implementer from using 16 bit bytes.... : [Corrections gratefully accepted; I don't think ANSI mandated : sizeof(char) being one, although a lot of code will probably break if : it isn't.] Be grateful. From the May 13 draft, section 3.3.3.4: "When applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1." --- Bill {uunet|novavax}!proxftl!twwells!bill