strdup

Jordan Brown lcc.jbrown at ucla-locus.arpa
Wed Aug 27 04:38:19 AEST 1986


/* the following code is in the public domain.  I have never seen */
/* the original UNIX code for this function. */
/* hjb 08/25/86 */

char *
strdup(s)
char *s;
{
	char *p;
	extern char *malloc();

	if(p=malloc(strlen(s)+1))
		strcpy(p,s);
	return p;
}

I am not sure, but I think that strdup comes from MicroSoft, and is only
present under XENIX and their MSDOS C compiler.  It's a useful function,
though, and everybody should have it.



More information about the Comp.unix mailing list