diff options
author | Leah Neukirchen <leah@vuxu.org> | 2021-11-06 19:12:19 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2021-11-06 19:12:19 +0100 |
commit | d2b694a313ecb8fb8a4c510c2f229b07543fe8a9 (patch) | |
tree | 460547073fa0730feb2aa9a0d8b5d01e98e91992 | |
parent | 8ba5282b9982e1d49199f816a1ec4148a232d8df (diff) | |
download | libste-d2b694a313ecb8fb8a4c510c2f229b07543fe8a9.tar.gz libste-d2b694a313ecb8fb8a4c510c2f229b07543fe8a9.tar.xz libste-d2b694a313ecb8fb8a4c510c2f229b07543fe8a9.zip |
add stecpy alternative implementation using memccpy
-rw-r--r-- | stecpy-memccpy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/stecpy-memccpy.c b/stecpy-memccpy.c new file mode 100644 index 0000000..e4ce259 --- /dev/null +++ b/stecpy-memccpy.c @@ -0,0 +1,16 @@ +#include <string.h> + +char * +stecpy(char *dst, char *end, const char *src) +{ + if (dst >= end) + return dst; + + dst = memccpy(dst, src, '\0', end - dst); + if (!dst) { + end[-1] = 0; + return end; + } + + return dst - 1; +} |