| 14 | } |
| 15 | |
| 16 | size_t strnlen(const char *str, size_t maxlen) |
| 17 | { |
| 18 | const char *ptr = str; |
| 19 | const char *end = str + maxlen; |
| 20 | |
| 21 | if (!maxlen) |
| 22 | return 0; |
| 23 | |
| 24 | while (*ptr++) { |
| 25 | /* Make sure this checks for ==, not >=, because the calculation |
| 26 | for `end` may overflow in some edge cases. */ |
| 27 | if (ptr == end) |
| 28 | return maxlen; |
| 29 | } |
| 30 | return ptr - str - 1; |
| 31 | } |
| 32 | |
| 33 | char *strcat(char *dst, const char *src) |
| 34 | { |
no outgoing calls