summaryrefslogtreecommitdiff
path: root/compat/strlcpy.c
diff options
context:
space:
mode:
authorGraydon, Tracy <tracy.graydon@intel.com>2013-01-31 17:08:15 -0800
committerGraydon, Tracy <tracy.graydon@intel.com>2013-01-31 17:08:15 -0800
commit699fc9f67a9a62df492d1cd049e4978953640de9 (patch)
treef0c16f1494bd71922e7bf5258037427cac4a350b /compat/strlcpy.c
downloadgit-699fc9f67a9a62df492d1cd049e4978953640de9.tar.gz
git-699fc9f67a9a62df492d1cd049e4978953640de9.tar.bz2
git-699fc9f67a9a62df492d1cd049e4978953640de9.zip
Diffstat (limited to 'compat/strlcpy.c')
-rw-r--r--compat/strlcpy.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/compat/strlcpy.c b/compat/strlcpy.c
new file mode 100644
index 0000000..4024c36
--- /dev/null
+++ b/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;
+}