upload android base code part8
This commit is contained in:
parent
841ae54672
commit
5425409085
57075 changed files with 9846578 additions and 0 deletions
27
android/toolchain/binutils/binutils-2.25/libiberty/strdup.c
Normal file
27
android/toolchain/binutils/binutils-2.25/libiberty/strdup.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
|
||||
@deftypefn Supplemental char* strdup (const char *@var{s})
|
||||
|
||||
Returns a pointer to a copy of @var{s} in memory obtained from
|
||||
@code{malloc}, or @code{NULL} if insufficient memory was available.
|
||||
|
||||
@end deftypefn
|
||||
|
||||
*/
|
||||
|
||||
#include <ansidecl.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern size_t strlen (const char*);
|
||||
extern PTR malloc (size_t);
|
||||
extern PTR memcpy (PTR, const PTR, size_t);
|
||||
|
||||
char *
|
||||
strdup(const char *s)
|
||||
{
|
||||
size_t len = strlen (s) + 1;
|
||||
char *result = (char*) malloc (len);
|
||||
if (result == (char*) 0)
|
||||
return (char*) 0;
|
||||
return (char*) memcpy (result, s, len);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue