diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-02-09 14:28:17 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-02-09 14:28:17 -0500 |
commit | dd20f8f7ca634d375c54c1f9d27a19bc8ca4f5e1 (patch) | |
tree | e37dff576e6598ba61e9cd1f652fe5253db78a14 /src/string | |
parent | 7b7cca986ed85ecb2dd8d39478088f236a24b9a1 (diff) |
merge XOPEN identifiers
Diffstat (limited to 'src/string')
-rw-r--r-- | src/string/memccpy.c | 20 | ||||
-rw-r--r-- | src/string/strdup.c | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/string/memccpy.c b/src/string/memccpy.c new file mode 100644 index 00000000..a6aa6372 --- /dev/null +++ b/src/string/memccpy.c @@ -0,0 +1,20 @@ +#include <string.h> + +void *memccpy(void * restrict s1, const void * restrict s2, int c, size_t n) +{ + //__ASSERT_NOOVERLAP(s1, s2, n); + + unsigned char *dst = s1; + const unsigned char *src = s2; + for (size_t i = 0; i < n; i++) { + dst[i] = src[i]; + if (dst[i] == (unsigned char)c) { + return dst + i + 1; + } + } + return NULL; +} + +/* +XOPEN(4) +*/ diff --git a/src/string/strdup.c b/src/string/strdup.c new file mode 100644 index 00000000..2875796c --- /dev/null +++ b/src/string/strdup.c @@ -0,0 +1,11 @@ +#include <string.h> + +char * strdup(const char *s) +{ + return strndup (s, strlen (s)); +} + +/* +XOPEN(400) +POSIX(200809) +*/ |