From 754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 20 Jun 2011 16:54:15 +0930 Subject: lib: import ccan modules for tdb2 Imported from git://git.ozlabs.org/~ccan/ccan init-1161-g661d41f Signed-off-by: Rusty Russell --- lib/ccan/str/str.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/ccan/str/str.c (limited to 'lib/ccan/str/str.c') diff --git a/lib/ccan/str/str.c b/lib/ccan/str/str.c new file mode 100644 index 00000000000..fa9809fbd94 --- /dev/null +++ b/lib/ccan/str/str.c @@ -0,0 +1,12 @@ +#include + +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; +} -- cgit