summaryrefslogtreecommitdiff
path: root/lib/ccan/str/str.c
blob: 0271a59885f0c5cdd3f1445f1f1abd2158df8f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* Licensed under LGPLv2.1+ - see LICENSE file for details */
#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;
}