diff options
Diffstat (limited to 'libbb/strlcpy.c')
-rw-r--r-- | libbb/strlcpy.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libbb/strlcpy.c b/libbb/strlcpy.c new file mode 100644 index 000000000..4024c3603 --- /dev/null +++ b/libbb/strlcpy.c | |||
@@ -0,0 +1,13 @@ | |||
1 | #include "../git-compat-util.h" | ||
2 | |||
3 | size_t gitstrlcpy(char *dest, const char *src, size_t size) | ||
4 | { | ||
5 | size_t ret = strlen(src); | ||
6 | |||
7 | if (size) { | ||
8 | size_t len = (ret >= size) ? size - 1 : ret; | ||
9 | memcpy(dest, src, len); | ||
10 | dest[len] = '\0'; | ||
11 | } | ||
12 | return ret; | ||
13 | } | ||