]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/strdup.c
RISC-V: Add early clobber to the dest of vwsll
[thirdparty/gcc.git] / libiberty / strdup.c
CommitLineData
aaa5f039
DD
1/*
2
3@deftypefn Supplemental char* strdup (const char *@var{s})
4
5Returns a pointer to a copy of @var{s} in memory obtained from
7f8fa05d 6@code{malloc}, or @code{NULL} if insufficient memory was available.
aaa5f039
DD
7
8@end deftypefn
9
10*/
11
88702c45 12#include <ansidecl.h>
88702c45 13#include <stddef.h>
88702c45 14
885f2199 15extern size_t strlen (const char*);
50b009c5
ML
16extern void *malloc (size_t);
17extern void *memcpy (void *, const void *, size_t);
88702c45 18
6599da04 19char *
885f2199 20strdup(const char *s)
6599da04 21{
88702c45
RS
22 size_t len = strlen (s) + 1;
23 char *result = (char*) malloc (len);
24 if (result == (char*) 0)
25 return (char*) 0;
26 return (char*) memcpy (result, s, len);
6599da04 27}