mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:52:57 +00:00
now introducing the POSIX+ client DLL! (my first check-in, hope I don't f*** up something)
svn path=/trunk/; revision=2634
This commit is contained in:
parent
4e9d91b819
commit
ad8ae0a2f5
43 changed files with 4239 additions and 0 deletions
44
posix/lib/psxdll/string/strdup.c
Normal file
44
posix/lib/psxdll/string/strdup.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* $Id:
|
||||
*/
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: subsys/psx/lib/psxdll/string/strdup.c
|
||||
* PURPOSE: duplicate a string
|
||||
* PROGRAMMER: KJK::Hyperion <noog@libero.it>
|
||||
* UPDATE HISTORY:
|
||||
* 21/01/2002: Created
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <psx/debug.h>
|
||||
|
||||
char *strdup(const char *s1)
|
||||
{
|
||||
char *pchRetBuf;
|
||||
int nStrLen;
|
||||
|
||||
HINT("strdup() is inefficient - consider dropping zero-terminated strings");
|
||||
|
||||
if (s1 == 0)
|
||||
return 0;
|
||||
|
||||
nStrLen = strlen(s1);
|
||||
|
||||
/* allocate enough buffer space for s1 and the null terminator */
|
||||
pchRetBuf = (char *) malloc(nStrLen + 1);
|
||||
|
||||
if (pchRetBuf == 0)
|
||||
/* memory allocation failed */
|
||||
return 0;
|
||||
|
||||
/* copy the string */
|
||||
strcpy(pchRetBuf, s1);
|
||||
|
||||
return pchRetBuf;
|
||||
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue