diff options
Diffstat (limited to 'lib/ccan/str/str.c')
-rw-r--r-- | lib/ccan/str/str.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/ccan/str/str.c b/lib/ccan/str/str.c new file mode 100644 index 0000000000..fa9809fbd9 --- /dev/null +++ b/lib/ccan/str/str.c @@ -0,0 +1,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; +} |