1 /* 2 * Copyright (c) 1988 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)strdup.c 5.4 (Berkeley) 02/24/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <stddef.h> 13 #include <stdlib.h> 14 #include <string.h> 15 16 char * 17 strdup(str) 18 const char *str; 19 { 20 int len; 21 char *copy; 22 23 len = strlen(str) + 1; 24 if (!(copy = malloc((u_int)len))) 25 return((char *)NULL); 26 bcopy(str, copy, len); 27 return(copy); 28 } 29