summaryrefslogtreecommitdiff
path: root/src/libstddjb/byte_count.c
blob: a09e044fbd1bf2b60a528bf0c5774e8ee2c718b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
/* ISC license. */

#include <sys/types.h>
#include <skalibs/bytestr.h>

size_t byte_count (char const *s, size_t len, char b)
{
  size_t n = 0 ;
  while (len--) if (*s++ == b) n++ ;
  return n ;
}