• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/xnu-2422.115.4/libkern/

Lines Matching refs:sp

165 static void init_state(struct encode_state *sp)
169 bzero(sp, sizeof(*sp));
172 sp->text_buf[i] = ' ';
174 sp->rchild[i] = NIL;
176 sp->parent[i] = NIL;
187 static void insert_node(struct encode_state *sp, int r)
193 key = &sp->text_buf[r];
195 sp->rchild[r] = sp->lchild[r] = NIL;
196 sp->match_length = 0;
199 if (sp->rchild[p] != NIL)
200 p = sp->rchild[p];
202 sp->rchild[p] = r;
203 sp->parent[r] = p;
207 if (sp->lchild[p] != NIL)
208 p = sp->lchild[p];
210 sp->lchild[p] = r;
211 sp->parent[r] = p;
216 if ((cmp = key[i] - sp->text_buf[p + i]) != 0)
219 if (i > sp->match_length) {
220 sp->match_position = p;
221 if ((sp->match_length = i) >= F)
225 sp->parent[r] = sp->parent[p];
226 sp->lchild[r] = sp->lchild[p];
227 sp->rchild[r] = sp->rchild[p];
228 sp->parent[sp->lchild[p]] = r;
229 sp->parent[sp->rchild[p]] = r;
230 if (sp->rchild[sp->parent[p]] == p)
231 sp->rchild[sp->parent[p]] = r;
233 sp->lchild[sp->parent[p]] = r;
234 sp->parent[p] = NIL; /* remove p */
238 static void delete_node(struct encode_state *sp, int p)
242 if (sp->parent[p] == NIL)
244 if (sp->rchild[p] == NIL)
245 q = sp->lchild[p];
246 else if (sp->lchild[p] == NIL)
247 q = sp->rchild[p];
249 q = sp->lchild[p];
250 if (sp->rchild[q] != NIL) {
252 q = sp->rchild[q];
253 } while (sp->rchild[q] != NIL);
254 sp->rchild[sp->parent[q]] = sp->lchild[q];
255 sp->parent[sp->lchild[q]] = sp->parent[q];
256 sp->lchild[q] = sp->lchild[p];
257 sp->parent[sp->lchild[p]] = q;
259 sp->rchild[q] = sp->rchild[p];
260 sp->parent[sp->rchild[p]] = q;
262 sp->parent[q] = sp->parent[p];
263 if (sp->rchild[sp->parent[p]] == p)
264 sp->rchild[sp->parent[p]] = q;
266 sp->lchild[sp->parent[p]] = q;
267 sp->parent[p] = NIL;