diff options
Diffstat (limited to 'lib/xstrncpy.c')
-rw-r--r-- | lib/xstrncpy.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/xstrncpy.c b/lib/xstrncpy.c new file mode 100644 index 000000000..cf4940971 --- /dev/null +++ b/lib/xstrncpy.c @@ -0,0 +1,9 @@ +/* NUL-terminated version of strncpy() */ +#include <string.h> +#include "xstrncpy.h" + +void +xstrncpy(char *dest, const char *src, size_t n) { + strncpy(dest, src, n-1); + dest[n-1] = 0; +} |