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*56963Sbostic static char sccsid[] = "@(#)strdup.c 5.5 (Berkeley) 12/02/92"; 1036335Sbostic #endif /* LIBC_SCCS and not lint */ 1136335Sbostic 12*56963Sbostic #include <sys/types.h> 13*56963Sbostic 1442181Sbostic #include <stddef.h> 1546613Sbostic #include <stdlib.h> 1642181Sbostic #include <string.h> 1736335Sbostic 1836335Sbostic char * 1936335Sbostic strdup(str) 2046613Sbostic const char *str; 2136335Sbostic { 22*56963Sbostic size_t len; 2346613Sbostic char *copy; 2436335Sbostic 2536335Sbostic len = strlen(str) + 1; 2636335Sbostic if (!(copy = malloc((u_int)len))) 27*56963Sbostic return (NULL); 2836335Sbostic bcopy(str, copy, len); 29*56963Sbostic return (copy); 3036335Sbostic } 31