Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!oliveb!pyramid!prls!philabs!gcm!dc From: dc@gcm (Dave Caswell) Newsgroups: comp.lang.c Subject: Re: hardcoded constants Message-ID: <652@white.gcm> Date: 22 Dec 88 08:05:38 GMT References: <2636@m2-net.UUCP> <1104@goofy.megatest.UUCP> Reply-To: dc@white.UUCP (Dave Caswell) Organization: Greenwich Capital Markets, Greenwich, CT Lines: 22 John H. Remmers writes > The space requirement for a string concatenation is a frequently-needed > value; it's worth having a macro to represent it: > > #define Catspace(s,t) (strlen(s) + strlen(t) + 1) and Dave Jones rambles . .foo = malloc( strlen(s) + strlen(t) + sizeof('\0')); | |--this is four on 32-bit machines .Tells it all. And keeps the reader on track, not grepping around .for macros. An advantage of functions or macros is what you write it once and debug it; you cut down the chance of errors. I wouldn't mind searching for code what worked. -- Dave Caswell (former EMU student) Greenwich Capital Markets uunet!philabs!gcm!dc