136335Sbostic /* 236335Sbostic * Copyright (c) 1988 The Regents of the University of California. 336335Sbostic * All rights reserved. 436335Sbostic * 542635Sbostic * %sccs.include.redist.c% 636335Sbostic */ 736335Sbostic 836335Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*46613Sbostic static char sccsid[] = "@(#)strdup.c 5.4 (Berkeley) 02/24/91"; 1036335Sbostic #endif /* LIBC_SCCS and not lint */ 1136335Sbostic 1242181Sbostic #include <stddef.h> 13*46613Sbostic #include <stdlib.h> 1442181Sbostic #include <string.h> 1536335Sbostic 1636335Sbostic char * 1736335Sbostic strdup(str) 18*46613Sbostic const char *str; 1936335Sbostic { 2036335Sbostic int len; 21*46613Sbostic char *copy; 2236335Sbostic 2336335Sbostic len = strlen(str) + 1; 2436335Sbostic if (!(copy = malloc((u_int)len))) 2536335Sbostic return((char *)NULL); 2636335Sbostic bcopy(str, copy, len); 2736335Sbostic return(copy); 2836335Sbostic } 29