diff options
Diffstat (limited to 'compat/strlcpy.c')
-rw-r--r-- | compat/strlcpy.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compat/strlcpy.c b/compat/strlcpy.c new file mode 100644 index 000000000..b66856a3a --- /dev/null +++ b/compat/strlcpy.c @@ -0,0 +1,13 @@ +#include <string.h> + +size_t gitstrlcpy(char *dest, const char *src, size_t size) +{ + size_t ret = strlen(src); + + if (size) { + size_t len = (ret >= size) ? size - 1 : ret; + memcpy(dest, src, len); + dest[len] = '\0'; + } + return ret; +} |