Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
Main Page
Related Pages
+
Classes
Class List
Class Index
+
Class Members
+
All
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Variables
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
u
v
w
+
Variables
_
b
c
d
e
f
h
i
l
n
p
t
v
w
+
Typedefs
_
a
b
c
d
f
i
j
n
s
t
u
v
w
Enumerator
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerator
Macros
Pages
strnlen.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
3
*
4
* Permission to use, copy, modify, and distribute this software for any
5
* purpose with or without fee is hereby granted, provided that the above
6
* copyright notice and this permission notice appear in all copies.
7
*
8
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
*/
16
17
/* $OpenBSD: strnlen.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */
18
19
#include <
string.h
>
20
21
size_t
strnlen
(
const
char
* str,
size_t
maxlen)
22
{
23
const
char
* cp;
24
25
for
(cp = str; maxlen != 0 && *cp !=
'\0'
; cp++, maxlen--)
26
{
27
{
28
;
29
}
30
}
31
32
return
(
size_t
)(cp - str);
33
}
string.h
strnlen
size_t strnlen(const char *str, size_t maxlen)
Returns the length of the given null-terminated byte string.
Definition:
strnlen.c:21
src
string
strnlen.c
Generated by
1.8.15