Commit | Line | Data |
---|---|---|
4a5f8f09 KB |
1 | /* |
2 | * Copyright (c) 1988 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
019bea33 | 5 | * %sccs.include.redist.c% |
4a5f8f09 KB |
6 | */ |
7 | ||
8 | #if defined(LIBC_SCCS) && !defined(lint) | |
46b5f26a | 9 | static char sccsid[] = "@(#)strdup.c 5.4 (Berkeley) %G%"; |
4a5f8f09 KB |
10 | #endif /* LIBC_SCCS and not lint */ |
11 | ||
336401ac | 12 | #include <stddef.h> |
46b5f26a | 13 | #include <stdlib.h> |
336401ac KB |
14 | #include <string.h> |
15 | ||
4a5f8f09 KB |
16 | char * |
17 | strdup(str) | |
46b5f26a | 18 | const char *str; |
4a5f8f09 KB |
19 | { |
20 | int len; | |
46b5f26a | 21 | char *copy; |
4a5f8f09 KB |
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 | } |