summaryrefslogtreecommitdiff
path: root/lib/ccan/str/str.c
blob: fa9809fbd94d3670ac6190697f253f9c208b4342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#include <ccan/str/str.h>

size_t strcount(const char *haystack, const char *needle)
{
	size_t i = 0, nlen = strlen(needle);

	while ((haystack = strstr(haystack, needle)) != NULL) {
		i++;
		haystack += nlen;
	}
	return i;
}