Details
- Reviewers
sivachandra - Commits
- rG5a9630b7774d: [libc] Adds implementation for memrchr.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | I think this will be a trouble if n == 0 because n is unsigned. |
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | You're right. Good catch, thanks. |
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | Fixed, and added a test where size is 0. |
This is a GNU extension. So, you need to add entry to https://github.com/llvm/llvm-project/blob/master/libc/spec/gnu_ext.td and linux's api.td.
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | For better readability, may be: for (; n != 0; --n) { ... } |
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | Are you looking for something along these lines: for (; n != 0; --n) { if (str[n] == ch) return const_cast<unsigned char *>(str + n); } return str[0] == ch ? const_cast<unsigned char *>(str) : nullptr; Or, am I missing something simpler here? |
libc/src/string/memrchr.cpp | ||
---|---|---|
19 | Very close: for (; n != 0; --n) { const unsigned char *s = str + n - 1; if (*s == ch) return const_cast<unsigned char *>(s); } return nullptr; The post decrement you have currently makes it easy miss that n - 1 offset. |
libc/config/linux/aarch64/entrypoints.txt | ||
---|---|---|
16 | I missed in the previous reviews, but can you please sort these lists alphabetically. |
libc/config/linux/aarch64/entrypoints.txt | ||
---|---|---|
16 | Are you OK with me doing this in a separate commit? |
libc/config/linux/aarch64/entrypoints.txt | ||
---|---|---|
16 | OK. |
I missed in the previous reviews, but can you please sort these lists alphabetically.