Function ndpi_memmem

Function Documentation

void *ndpi_memmem(const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)

Finds the first occurrence of the sequence needle in the array haystack.

This function searches for the first occurrence of the sequence needle of length needle_len in the array haystack of length haystack_len. If haystack or needle is NULL, or haystack_len is less than needle_len, or needle_len is 0, the function returns NULL.

For optimization, if needle_len is 1, the memchr function is used.

Return
Pointer to the first occurrence of needle in haystack or NULL if needle is not found.
Parameters
  • haystack: Pointer to the array in which the search is performed.
  • haystack_len: Length of the haystack array.
  • needle: Pointer to the array to be searched for in haystack.
  • needle_len: Length of the needle array.