Add include files to get prototype declarations, and fix bugs found.
[unix-history] / usr / src / lib / libc / string / strdup.c
... / ...
CommitLineData
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)
9static char sccsid[] = "@(#)strdup.c 5.4 (Berkeley) %G%";
10#endif /* LIBC_SCCS and not lint */
11
12#include <stddef.h>
13#include <stdlib.h>
14#include <string.h>
15
16char *
17strdup(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}