Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!ogicse!pdxgate!parsely!percy!qiclab!onion!jeff From: jeff@onion.rain.com (Jeff Beadles) Newsgroups: comp.sources.wanted Subject: Re: What is strdup() supposed to do? Does anyone have a copy? Message-ID: <1991Feb22.041225.17560@onion.rain.com> Date: 22 Feb 91 04:12:25 GMT References: <1991Feb17.045913.17126@sbcs.sunysb.edu> <1991Feb17.164731.7564@onion.rain.com> Lines: 28 In guido@cwi.nl (Guido van Rossum) writes: >jeff@onion.rain.com (Jeff Beadles) writes: > >>Strcpy could also return an error, but I don't think that I've ever seen >>someone check for it. :-) > >Actually, it is documented behaviour (at least on some systems) that >it returns NULL when the malloc fails. I have written code that >assumes this. > >--Guido (what a silly thread this is!) Your strcpy malloc's space? Weird... I'd like to see the source to this routine, or how you know that your's is using malloc. Strcpy is just a copy function, that copies bytes until it reaches a null byte. Maybe your version of strcpy() checks to see if either the source or destination string is a null pointer? This sounds more likely. From the sources on uunet in the bsd archives, there's no malloc. It does however, return a pointer to the destination string. Regarding the +1 stuff, there was no trailing ')'. That's why I said what I did. It's true, based on the information that I had at the time. -Jeff -- Jeff Beadles jeff@onion.rain.com