Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!hc!beta!myxm From: myxm@beta.UUCP (Mike Mitchell) Newsgroups: comp.unix.xenix Subject: strings(3) on uport !!HELP!! Message-ID: <10979@beta.UUCP> Date: Wed, 7-Oct-87 12:43:20 EDT Article-I.D.: beta.10979 Posted: Wed Oct 7 12:43:20 1987 Date-Received: Sat, 10-Oct-87 09:44:14 EDT Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 43 I have been working on porting down some of my more favorite utilities from a BSD4.3 machine to uport sysv and I have been hitting some really nasty problems. I was wondering if someone might have a nifty solution. Basically the problem occurs with some of the routines which manipulate (char *) pointers. There is a call to strdup in one of my utilities which I wound up writing with the following code: char *strdup(str) char *str; { return(strcpy((char *)malloc(strlen(str)+1),str)); } This routine functions anywhere between 0 and 5 times before it bombs. I have been compiling with the large memory model and using the "debug printfs" to watch it work. In using sdb to find out what died from the core dump, the stack shows that strcpy was the routine which gave up the ghost. I figured that I could write a strcpy which looks like: char *strcpy(str1, str2) char *str1, *str2; { char *sp; for (sp = str1; *str2 != 0; sp++, str2++) *sp = *str2; *sp = 0; return(str1); } Now this works fine for a few calls, but then it pukes up and dies! This thing is not doing anything real fancy so is there some trick with the segmented large model that I am missing out on? There are no bizzarre pointer manipulations in this piece of code... Thanks for any information which may help me out of this situation. Mike Mitchell myxm@lanl.gov ...!cmcl2!lanl!myxm