strlen.c 258 B

1234567891011121314151617181920212223
  1. #include <string.h>
  2. __attribute__((used))
  3. size_t strlen(const char *s)
  4. {
  5. size_t n = 0;
  6. while (*s++)
  7. n++;
  8. return n;
  9. }
  10. __attribute__((used))
  11. size_t strnlen(const char *s, size_t maxlen)
  12. {
  13. size_t n = 0;
  14. while (*s++ && maxlen--)
  15. n++;
  16. return n;
  17. }