merge ROS Shell without integrated explorer part into trunk
[reactos.git] / posix / lib / psxdll / string / strdup.c
1 /* $Id: strdup.c,v 1.4 2002/10/29 04:45:42 rex Exp $
2 */
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/string/strdup.c
7 * PURPOSE: Duplicate a string
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * UPDATE HISTORY:
10 * 21/01/2002: Created
11 */
12
13 #include <string.h>
14 #include <stdlib.h>
15 #include <psx/debug.h>
16
17 char *strdup(const char *s1)
18 {
19 char *pchRetBuf;
20 int nStrLen;
21
22 HINT("strdup() is inefficient - consider dropping zero-terminated strings");
23
24 if (s1 == 0)
25 return 0;
26
27 nStrLen = strlen(s1);
28
29 /* allocate enough buffer space for s1 and the null terminator */
30 pchRetBuf = (char *) malloc(nStrLen + 1);
31
32 if (pchRetBuf == 0)
33 /* memory allocation failed */
34 return 0;
35
36 /* copy the string */
37 strcpy(pchRetBuf, s1);
38
39 return pchRetBuf;
40
41 }
42
43 /* EOF */
44