1 /* CC0 (Public domain) - see LICENSE file for details */
2 #include <ccan/str/str.h>
3 
strcount(const char * haystack,const char * needle)4 size_t strcount(const char *haystack, const char *needle)
5 {
6 	size_t i = 0, nlen = strlen(needle);
7 
8 	while ((haystack = strstr(haystack, needle)) != NULL) {
9 		i++;
10 		haystack += nlen;
11 	}
12 	return i;
13 }
14