about summary refs log tree commit diff
path: root/src/libstddjb/byte_search.c
blob: 286d8065527e6b2c6266c74932d7af2d4a6cc468 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
/* ISC license. */

#include <string.h>
#include <skalibs/posixplz.h>
#include <skalibs/bytestr.h>

size_t byte_search (char const *haystack, size_t hlen, char const *needle, size_t nlen)
{
  char *p = memmem(haystack, hlen, needle, nlen) ;
  return p ? p - haystack : hlen + 1 - nlen ;
}