136335Sbostic /* 2*61193Sbostic * Copyright (c) 1988, 1993 3*61193Sbostic * The Regents of the University of California. All rights reserved. 436335Sbostic * 542635Sbostic * %sccs.include.redist.c% 636335Sbostic */ 736335Sbostic 836335Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*61193Sbostic static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 06/04/93"; 1036335Sbostic #endif /* LIBC_SCCS and not lint */ 1136335Sbostic 1256963Sbostic #include <sys/types.h> 1356963Sbostic 1442181Sbostic #include <stddef.h> 1546613Sbostic #include <stdlib.h> 1642181Sbostic #include <string.h> 1736335Sbostic 1836335Sbostic char * strdup(str)1936335Sbosticstrdup(str) 2046613Sbostic const char *str; 2136335Sbostic { 2256963Sbostic size_t len; 2346613Sbostic char *copy; 2436335Sbostic 2536335Sbostic len = strlen(str) + 1; 2636335Sbostic if (!(copy = malloc((u_int)len))) 2756963Sbostic return (NULL); 2836335Sbostic bcopy(str, copy, len); 2956963Sbostic return (copy); 3036335Sbostic } 31