Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: What is strdup() supposed to do? Does anyone have a copy? Message-ID: <6151@auspex.auspex.com> Date: 19 Feb 91 18:54:04 GMT References: <1991Feb18.154159.430@persoft.com> <1991Feb19.004526.16033@onion.rain.com> Organization: Auspex Systems, Santa Clara Lines: 24 > A creature of habit, I suppose. I've been bitten too often when I return > something from a function that isn't static. (int's, for example.) For > this case, it really doesn't matter. > >I would suggest that if you can't tell the difference between a value >that is safe to return from a function, and a value that is not, >you're better off letting other people post code to the net. Yup. I'm really curious how the poster to whom you're responding had gotten bitten by returning a non-static "int"; other code does so successfully all the time. The place where you tend to get bitten is when you return a pointer *to* something that's not static, not when you return something that's not static.... > Untrue. What if sizeof(char) != 1? Yours will break, and mine will work. > >You're wrong. Both expressions above will result in the proper value, >whether sizeof(char) is 1 or not. And, on top of that, to quote the ANSI C standard: When applied to an operand that has type "char", "unsigned char", or "signed char", (or a qualified version thereof) the result is 1.