about summary refs log tree commit diff
path: root/third_party/git/compat/strlcpy.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/compat/strlcpy.c')
-rw-r--r--third_party/git/compat/strlcpy.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/third_party/git/compat/strlcpy.c b/third_party/git/compat/strlcpy.c
new file mode 100644
index 000000000000..4024c360301e
--- /dev/null
+++ b/third_party/git/compat/strlcpy.c
@@ -0,0 +1,13 @@
+#include "../git-compat-util.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;
+}