Start working on a VFS implementation #22
@ -22,6 +22,8 @@ extern "C"
|
||||
// FIXME: Replace this invented function with strlcpy().
|
||||
void nullcpy(char* dest, const char* src, usize len);
|
||||
|
||||
usize strlcpy(char* dest, const char* src, usize len);
|
||||
|
||||
[[deprecated]] char* strcpy(char* dst, const char* src);
|
||||
[[deprecated]] char* strcat(char* dst, const char* src);
|
||||
|
||||
|
@ -125,4 +125,15 @@ extern "C"
|
||||
if (*str) return const_cast<char*>(str);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
usize strlcpy(char* dest, const char* src, usize len)
|
||||
{
|
||||
usize src_len = strlen(src);
|
||||
usize copy_len = src_len;
|
||||
if (len == 0) return src_len;
|
||||
if (src_len >= (len - 1)) copy_len = len - 1;
|
||||
memcpy(dest, src, copy_len);
|
||||
dest[copy_len] = 0;
|
||||
return src_len;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user