Lines Matching +full:1 +full:k
29 twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in twobyte_memmem() argument
31 uint16_t nw = n[0] << 8 | n[1], hw = h[0] << 8 | h[1]; in twobyte_memmem()
32 for (h += 2, k -= 2; k; k--, hw = hw << 8 | *h++) in twobyte_memmem()
39 threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in threebyte_memmem() argument
41 uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8; in threebyte_memmem()
42 uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8; in threebyte_memmem()
43 for (h += 3, k -= 3; k; k--, hw = (hw | *h++) << 8) in threebyte_memmem()
50 fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in fourbyte_memmem() argument
52 uint32_t nw = (uint32_t)n[0] << 24 | n[1] << 16 | n[2] << 8 | n[3]; in fourbyte_memmem()
53 uint32_t hw = (uint32_t)h[0] << 24 | h[1] << 16 | h[2] << 8 | h[3]; in fourbyte_memmem()
54 for (h += 4, k -= 4; k; k--, hw = hw << 8 | *h++) in fourbyte_memmem()
65 (size_t)1 << ((size_t)(b) % (8 * sizeof *(a))))
70 * initialized to avoid fully initializing a 1kb/2kb table.
79 size_t i, ip, jp, k, p, ms, p0, mem, mem0; in twoway_memmem() local
85 BITOP(byteset, n[i], |=), shift[n[i]] = i + 1; in twoway_memmem()
88 ip = -1; in twoway_memmem()
90 k = p = 1; in twoway_memmem()
91 while (jp + k < l) { in twoway_memmem()
92 if (n[ip + k] == n[jp + k]) { in twoway_memmem()
93 if (k == p) { in twoway_memmem()
95 k = 1; in twoway_memmem()
97 k++; in twoway_memmem()
98 } else if (n[ip + k] > n[jp + k]) { in twoway_memmem()
99 jp += k; in twoway_memmem()
100 k = 1; in twoway_memmem()
104 k = p = 1; in twoway_memmem()
111 ip = -1; in twoway_memmem()
113 k = p = 1; in twoway_memmem()
114 while (jp + k < l) { in twoway_memmem()
115 if (n[ip + k] == n[jp + k]) { in twoway_memmem()
116 if (k == p) { in twoway_memmem()
118 k = 1; in twoway_memmem()
120 k++; in twoway_memmem()
121 } else if (n[ip + k] < n[jp + k]) { in twoway_memmem()
122 jp += k; in twoway_memmem()
123 k = 1; in twoway_memmem()
127 k = p = 1; in twoway_memmem()
130 if (ip + 1 > ms + 1) in twoway_memmem()
136 if (memcmp(n, n + p, ms + 1)) { in twoway_memmem()
138 p = MAX(ms, l - ms - 1) + 1; in twoway_memmem()
150 if (BITOP(byteset, h[l - 1], &)) { in twoway_memmem()
151 k = l - shift[h[l - 1]]; in twoway_memmem()
152 if (k) { in twoway_memmem()
153 if (k < mem) in twoway_memmem()
154 k = mem; in twoway_memmem()
155 h += k; in twoway_memmem()
166 for (k = MAX(ms + 1, mem); k < l && n[k] == h[k]; k++) in twoway_memmem()
168 if (k < l) { in twoway_memmem()
169 h += k - ms; in twoway_memmem()
174 for (k = ms + 1; k > mem && n[k - 1] == h[k - 1]; k--) in twoway_memmem()
176 if (k <= mem) in twoway_memmem()
184 memmem(const void *h0, size_t k, const void *n0, size_t l) in memmem() argument
193 if (k < l) in memmem()
197 h = memchr(h0, *n, k); in memmem()
198 if (!h || l == 1) in memmem()
200 k -= h - (const unsigned char *)h0; in memmem()
201 if (k < l) in memmem()
204 return twobyte_memmem(h, k, n); in memmem()
206 return threebyte_memmem(h, k, n); in memmem()
208 return fourbyte_memmem(h, k, n); in memmem()
210 return twoway_memmem(h, h + k, n, l); in memmem()