summaryrefslogtreecommitdiff
path: root/src/string/strlen.c
blob: 2527a7fb4ed59dd68b0db73f2e85f068e317bbc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <string.h>
#include "_safety.h"

/** find string length **/
size_t strlen(const char *s)
{
	size_t i = 0;

	SIGNAL_SAFE(0);
	ASSERT_NONNULL(s);

	DANGEROUS_READ(s, -1);
	for (i = 0; s[i] != '\0'; i++) {
		continue;
	}
	DANGER_OVER();

	return i;
}

CHECK_1(size_t, 0, strlen, const char *)

/***
counts the number of bytes in the string ARGUMENT(s), not
including the terminating null character.
***/

/*
RETURN_ALWAYS(the length of the string);
STDC(1)
*/