summaryrefslogtreecommitdiffstats
path: root/ccan/ccan/str/str.c
diff options
context:
space:
mode:
Diffstat (limited to 'ccan/ccan/str/str.c')
-rw-r--r--ccan/ccan/str/str.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ccan/ccan/str/str.c b/ccan/ccan/str/str.c
new file mode 100644
index 0000000..a9245c1
--- /dev/null
+++ b/ccan/ccan/str/str.c
@@ -0,0 +1,13 @@
+/* CC0 (Public domain) - 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;
+}