Xref: utzoo comp.sources.wanted:15280 alt.sources.wanted:926 Path: utzoo!utgpu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.sources.wanted,alt.sources.wanted Subject: Re: What is strdup() supposed to do? Does anyone have a copy? Message-ID: <1991Feb15.014912.591@athena.mit.edu> Date: 15 Feb 91 01:49:12 GMT References: <1991Feb14.050716.9501@shibaya.lonestar.org> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 27 (Written for ANSI C.) #include /* strdup -- duplicate string in malloc'd memory */ char *strdup(char *str) { char *new, *ptr; if (! str) return(0); new = (char *) malloc(strlen(str) + 1); if (! new) return(0); for (ptr = new; *ptr++ = *str++; ) /* empty loop body */; return(new); } -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710