Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!tcdcs!csvax1!gsl3 From: gsl3@csvax1.cs.tcd.ie (Generics Software Ltd.) Newsgroups: comp.lang.c Subject: Re: Strcpy fun w/ UltrixREAD/NEW/FOLLOWUP Message-ID: <43745@csvax1.cs.tcd.ie> Date: 3 May 89 11:35:42 GMT References: Organization: Computer Science Department, Trinity College Dublin Lines: 29 In article , bobg+@andrew.cmu.edu (Robert Steven Glickstein) writes: >> Excerpts from ext.nn.comp.lang.c: 27-Apr-89 Strcpy fun w/ Ultrix >> tim@scsmo1.UUCP (618) > > >> I ran accross a problem with strcpy in ultrix, for some reason it will >> not return its first argument. This is something like the "buged" code: >> x->name=strcpy(malloc(strlen(in)+1),in); >> The solution was: >> strcpy(x->name=malloc(strlen(in)+1),in); > > Danger, Will Robinson! Bad programming style alert! > > Do you WANT to dump core if malloc returns NULL? > > -Bob Glickstein We should be so lucky, most of the ultrix implementation of string manipulation functions quite happily take a NULL pointer. I discovered this when porting the code to a VMS machine. It was promptly sick when passed the NULL pointer. The moral of the story, check your return values. Andy Trayler trayler@genrix.uucp trayler@genrix.ie ..!mcvax!einode!genrix!trayler | ... What, ME naive ! :^) |