Initial public busybox maemo commit, 3:1.10.2.legal-1osso12
[busybox4maemo] / debian / sfdisk / xstrncpy.c
diff --git a/debian/sfdisk/xstrncpy.c b/debian/sfdisk/xstrncpy.c
new file mode 100644 (file)
index 0000000..7975426
--- /dev/null
@@ -0,0 +1,10 @@
+/* NUL-terminated version of strncpy() */
+#include <string.h>
+#include "xstrncpy.h"
+
+/* caller guarantees n > 0 */
+void
+xstrncpy(char *dest, const char *src, size_t n) {
+       strncpy(dest, src, n-1);
+       dest[n-1] = 0;
+}