git-p4: improve import performance by avoiding reallocations.
[git/git-bigfiles.git] / compat / strlcpy.c
blob4024c360301ebe7d58ac5b84dcbb692341b649ed
1 #include "../git-compat-util.h"
3 size_t gitstrlcpy(char *dest, const char *src, size_t size)
5 size_t ret = strlen(src);
7 if (size) {
8 size_t len = (ret >= size) ? size - 1 : ret;
9 memcpy(dest, src, len);
10 dest[len] = '\0';
12 return ret;