You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

strnlen.cpp 509B

123456789101112131415161718
  1. // Copyright (c) 2009-2014 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #if defined(HAVE_CONFIG_H)
  5. #include "config/starwels-config.h"
  6. #endif
  7. #include <cstring>
  8. #if HAVE_DECL_STRNLEN == 0
  9. size_t strnlen( const char *start, size_t max_len)
  10. {
  11. const char *end = (const char *)memchr(start, '\0', max_len);
  12. return end ? (size_t)(end - start) : max_len;
  13. }
  14. #endif // HAVE_DECL_STRNLEN