136335Sbostic /* 236335Sbostic * Copyright (c) 1988 The Regents of the University of California. 336335Sbostic * All rights reserved. 436335Sbostic * 536335Sbostic * Redistribution and use in source and binary forms are permitted 636335Sbostic * provided that the above copyright notice and this paragraph are 736335Sbostic * duplicated in all such forms and that any documentation, 836335Sbostic * advertising materials, and other materials related to such 936335Sbostic * distribution and use acknowledge that the software was developed 1036335Sbostic * by the University of California, Berkeley. The name of the 1136335Sbostic * University may not be used to endorse or promote products derived 1236335Sbostic * from this software without specific prior written permission. 1336335Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 1436335Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 1536335Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1636335Sbostic */ 1736335Sbostic 1836335Sbostic #if defined(LIBC_SCCS) && !defined(lint) 19*42181Sbostic static char sccsid[] = "@(#)strdup.c 5.2 (Berkeley) 05/17/90"; 2036335Sbostic #endif /* LIBC_SCCS and not lint */ 2136335Sbostic 2236335Sbostic #include <sys/types.h> 23*42181Sbostic #include <stddef.h> 24*42181Sbostic #include <string.h> 2536335Sbostic 26*42181Sbostic 2736335Sbostic char * 2836335Sbostic strdup(str) 2936335Sbostic char *str; 3036335Sbostic { 3136335Sbostic int len; 3236335Sbostic char *copy, *malloc(); 3336335Sbostic 3436335Sbostic len = strlen(str) + 1; 3536335Sbostic if (!(copy = malloc((u_int)len))) 3636335Sbostic return((char *)NULL); 3736335Sbostic bcopy(str, copy, len); 3836335Sbostic return(copy); 3936335Sbostic } 40