src/compat.c
changeset 49 59b09b0aeb96
parent 13 d3554afaa768
--- a/src/compat.c
+++ b/src/compat.c
@@ -19,3 +19,18 @@
 
     return buf;
 }
+
+char *safe_strncpy (char *dest, const char *src, size_t size)
+{
+    size_t i;
+
+    for (i = 0; i < size - 1; i++) {
+        if (src[i] == '\0')
+            break;
+        dest[i] = src[i];
+    }
+
+    dest[i] = '\0';
+
+    return dest;
+}