diff options
author | Ben Cheng <bccheng@google.com> | 2013-04-09 11:29:01 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2013-04-09 11:29:01 -0700 |
commit | f226517827d64cc8f9dccb0952731601ac13ef2a (patch) | |
tree | 84b1056255b318a87b7a47b2684655660cab66f0 /binutils-2.23/libiberty/strdup.c | |
parent | 30fe22e2cc89991b16ab3853f95c7319574456ce (diff) | |
download | toolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.tar.gz toolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.tar.bz2 toolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.zip |
Initial checkin for binutils 2.23.2 (needed by aarch64)
Change-Id: I7e5f319e9e632cc0ccc8a4ec1051169ed2849ca4
Diffstat (limited to 'binutils-2.23/libiberty/strdup.c')
-rw-r--r-- | binutils-2.23/libiberty/strdup.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/binutils-2.23/libiberty/strdup.c b/binutils-2.23/libiberty/strdup.c new file mode 100644 index 00000000..78c2093b --- /dev/null +++ b/binutils-2.23/libiberty/strdup.c @@ -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); +} |