Lines Matching +full:1 +full:k
38 twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in twobyte_memmem() argument
40 uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; in twobyte_memmem()
41 for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) in twobyte_memmem()
47 threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in threebyte_memmem() argument
49 uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; in threebyte_memmem()
50 uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; in threebyte_memmem()
51 for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) in threebyte_memmem()
57 fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) in fourbyte_memmem() argument
59 uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; in fourbyte_memmem()
60 uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; in fourbyte_memmem()
61 for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) in fourbyte_memmem()
73 ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a))))
83 size_t i, ip, jp, k, p, ms, p0, mem, mem0; in twoway_memmem() local
89 BITOP(byteset, n[i], |=), shift[n[i]] = i+1; in twoway_memmem()
92 ip = -1; jp = 0; k = p = 1; in twoway_memmem()
93 while (jp+k<l) { in twoway_memmem()
94 if (n[ip+k] == n[jp+k]) { in twoway_memmem()
95 if (k == p) { in twoway_memmem()
97 k = 1; in twoway_memmem()
98 } else k++; in twoway_memmem()
99 } else if (n[ip+k] > n[jp+k]) { in twoway_memmem()
100 jp += k; in twoway_memmem()
101 k = 1; in twoway_memmem()
105 k = p = 1; in twoway_memmem()
112 ip = -1; jp = 0; k = p = 1; in twoway_memmem()
113 while (jp+k<l) { in twoway_memmem()
114 if (n[ip+k] == n[jp+k]) { in twoway_memmem()
115 if (k == p) { in twoway_memmem()
117 k = 1; in twoway_memmem()
118 } else k++; in twoway_memmem()
119 } else if (n[ip+k] < n[jp+k]) { in twoway_memmem()
120 jp += k; in twoway_memmem()
121 k = 1; in twoway_memmem()
125 k = p = 1; in twoway_memmem()
128 if (ip+1 > ms+1) ms = ip; in twoway_memmem()
132 if (memcmp(n, n+p, ms+1)) { in twoway_memmem()
134 p = MAX(ms, l-ms-1) + 1; in twoway_memmem()
144 if (BITOP(byteset, h[l-1], &)) { in twoway_memmem()
145 k = l-shift[h[l-1]]; in twoway_memmem()
146 if (k) { in twoway_memmem()
147 if (k < mem) k = mem; in twoway_memmem()
148 h += k; in twoway_memmem()
159 for (k=MAX(ms+1,mem); k<l && n[k] == h[k]; k++); in twoway_memmem()
160 if (k < l) { in twoway_memmem()
161 h += k-ms; in twoway_memmem()
166 for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); in twoway_memmem()
167 if (k <= mem) return (char *)h; in twoway_memmem()
174 memmem(const void *h0, size_t k, const void *n0, size_t l) in memmem() argument
182 if (k<l) return 0; in memmem()
185 h = memchr(h0, *n, k); in memmem()
186 if (!h || l==1) return (void *)h; in memmem()
187 k -= h - (const unsigned char *)h0; in memmem()
188 if (k<l) return 0; in memmem()
189 if (l==2) return twobyte_memmem(h, k, n); in memmem()
190 if (l==3) return threebyte_memmem(h, k, n); in memmem()
191 if (l==4) return fourbyte_memmem(h, k, n); in memmem()
193 return twoway_memmem(h, h+k, n, l); in memmem()