Details
- Reviewers
sivachandra lntue michaelrj - Commits
- rGfc2c8b2371d7: [libc] Add strlcpy
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Overall the patch looks good, I left some comments for the main code but the build system changes are good.
libc/src/string/strlcpy.cpp | ||
---|---|---|
24 | it doesn't seem like defining a min function is necessary here since it's only used once, I think it would be cleaner to write size_t len = internal::string_length(src) size_t n = len < size - 1 ? len : size - 1; This also helps for the return value. | |
27 | we're trying to keep entrypoints independent, meaning that they shouldn't include each other. In this case using inline_memset(reinterpret_cast<char *>(dst + n), 0, size - n); would be preferred. | |
28 | The return value of strlcpy is "the total length of the string they tried to create. For strlcpy() that means the length of src." |
it doesn't seem like defining a min function is necessary here since it's only used once, I think it would be cleaner to write
This also helps for the return value.