From: Urban Wallasch Date: Wed, 13 Nov 2019 14:54:38 +0000 (+0100) Subject: * Fixed types in mem_mem() and correctly attribute the search algorithm. X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=be355d29710fc0dbfca1ddb3e2948e418b01c281;p=riffx.git * Fixed types in mem_mem() and correctly attribute the search algorithm. --- diff --git a/riffx.c b/riffx.c index 7d2ee02..0ebed76 100644 --- a/riffx.c +++ b/riffx.c @@ -100,14 +100,19 @@ int mkdirp(const char *pathname, mode_t mode) { /* mem_mem * Locate needle of length nlen in haystack of length hlen. - * Returns pointer to first occurrence of needle in haystack or NULL. - * Uses the Boyer-Moore search algorithm. - * Cf. http://www-igm.univ-mlv.fr/~lecroq/string/node14.html + * Returns a pointer to the first occurrence of needle in haystack, or + * haystack for a needle of zero length, or NULL if needle was not found + * in haystack. + * + * Uses the Boyer-Moore-Horspool search algorithm, see + * https://en.wikipedia.org/wiki/Boyer–Moore–Horspool_algorithm + * + * For our tiny needles and non-pathologic haystacks this borders on + * overkill, but meh. */ static void *mem_mem(const void *haystack, size_t hlen, const void *needle, size_t nlen) { - size_t k; - int skip[256]; + size_t k, skip[256]; const uint8_t *hst = (const uint8_t *)haystack; const uint8_t *ndl = (const uint8_t *)needle;