Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!pasteur!agate!labrea!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: hardcoded constants Message-ID: <1104@goofy.megatest.UUCP> Date: 20 Dec 88 21:53:17 GMT References: <2636@m2-net.UUCP> Organization: Megatest Corporation, San Jose, Ca Lines: 22 From article <2636@m2-net.UUCP>, by remmers@m-net.UUCP (John H. Remmers): ... > 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) > You are a candidate for SLMA (Silly Little Macros Anonymous). There are no dues. Just get a sponsor and come to the meetings. Take it One Day At A Time, and soon you will no longer be sending innocent programmers poking through .h files in order to figure out what "Catspace" means. :-), in case you didn't guess. But if you don't like the naked "1", how about this? foo = malloc( strlen(s) + strlen(t) + sizeof('\0')); Tells it all. And keeps the reader on track, not grepping around for macros.