1 /*
2  * Copyright (c) 2014 Wind River Systems, Inc.
3  * Copyright (c) 2021 Nordic Semiconductor ASA
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <string.h>
9 #include <stdint.h>
10 #include <sys/types.h>
11 
12 /**
13  *
14  * @brief Get fixed-size string length
15  *
16  *        This function is not available in ARM C Standard library.
17  *
18  * @return number of bytes in fixed-size string <s>
19  */
20 
strnlen(const char * s,size_t maxlen)21 size_t strnlen(const char *s, size_t maxlen)
22 {
23 	size_t n = 0;
24 
25 	while (*s != '\0' && n < maxlen) {
26 		s++;
27 		n++;
28 	}
29 
30 	return n;
31 }
32