Xref: utzoo comp.lang.c:8665 comp.arch:4132 Path: utzoo!mnetor!uunet!husc6!mailrus!ames!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c,comp.arch Subject: Re: Bit Addressable Architectures Message-ID: <3216@haddock.ISC.COM> Date: 29 Mar 88 18:50:09 GMT References: <11702@brl-adm.ARPA> <243@eagle_snax.UUCP> <2245@geac.UUCP> <1988Mar6.002518.945@utzoo.uucp> <2760@mmintl.UUCP> <17458@watmath.waterloo.edu> <504@sol.warwick.ac.uk> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Followup-To: comp.lang.c Organization: Interactive Systems, Boston Lines: 15 Summary: Use sizeof(char) where applicable In article <504@sol.warwick.ac.uk> cudcv@cu.warwick.ac.uk (Rob McMahon) writes: >... or does everybody but me write "malloc((strlen(s)+1)*sizeof(char))" ? I do. It automatically makes the argument the right type$ for malloc() (assuming malloc's argument and sizeof's result are both unsigned, or size_t in ANSI C); and it makes it easier to convert when you later decide that you want to use some type other than char. And, of course, it makes the code no longer dependent on the questionable% sizeof(char)==1. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint Followups to comp.lang.c only. ________ $ Yes, strlen() is already a size_t in ANSI C, but this situation can also occur with int-valued expressions. % I don't question that it's true, just whether it's a good idea.