lib/libc/string0: Add strncpy() implementation.

This commit is contained in:
Paul Sokolovsky 2016-05-02 18:38:19 +03:00
parent 5302c3e8c4
commit bd9de5ec90
1 changed files with 9 additions and 0 deletions

View File

@ -169,6 +169,15 @@ char *strcpy(char *dest, const char *src) {
return dest;
}
char *strncpy(char *dest, const char *src, size_t dest_sz) {
char *d = dest;
while (*src && --dest_sz) {
*d++ = *src++;
}
*d = '\0';
return dest;
}
// needed because gcc optimises strcpy + strcat to this
char *stpcpy(char *dest, const char *src) {
while (*src) {