• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/kext_tools-326.95.1/

Lines Matching refs:sp

149 static void init_state(struct encode_state *sp)
153 bzero(sp, sizeof(*sp));
156 sp->text_buf[i] = ' ';
158 sp->rchild[i] = NIL;
160 sp->parent[i] = NIL;
171 static void insert_node(struct encode_state *sp, int r)
177 key = &sp->text_buf[r];
179 sp->rchild[r] = sp->lchild[r] = NIL;
180 sp->match_length = 0;
183 if (sp->rchild[p] != NIL)
184 p = sp->rchild[p];
186 sp->rchild[p] = r;
187 sp->parent[r] = p;
191 if (sp->lchild[p] != NIL)
192 p = sp->lchild[p];
194 sp->lchild[p] = r;
195 sp->parent[r] = p;
200 if ((cmp = key[i] - sp->text_buf[p + i]) != 0)
203 if (i > sp->match_length) {
204 sp->match_position = p;
205 if ((sp->match_length = i) >= F)
209 sp->parent[r] = sp->parent[p];
210 sp->lchild[r] = sp->lchild[p];
211 sp->rchild[r] = sp->rchild[p];
212 sp->parent[sp->lchild[p]] = r;
213 sp->parent[sp->rchild[p]] = r;
214 if (sp->rchild[sp->parent[p]] == p)
215 sp->rchild[sp->parent[p]] = r;
217 sp->lchild[sp->parent[p]] = r;
218 sp->parent[p] = NIL; /* remove p */
222 static void delete_node(struct encode_state *sp, int p)
226 if (sp->parent[p] == NIL)
228 if (sp->rchild[p] == NIL)
229 q = sp->lchild[p];
230 else if (sp->lchild[p] == NIL)
231 q = sp->rchild[p];
233 q = sp->lchild[p];
234 if (sp->rchild[q] != NIL) {
236 q = sp->rchild[q];
237 } while (sp->rchild[q] != NIL);
238 sp->rchild[sp->parent[q]] = sp->lchild[q];
239 sp->parent[sp->lchild[q]] = sp->parent[q];
240 sp->lchild[q] = sp->lchild[p];
241 sp->parent[sp->lchild[p]] = q;
243 sp->rchild[q] = sp->rchild[p];
244 sp->parent[sp->rchild[p]] = q;
246 sp->parent[q] = sp->parent[p];
247 if (sp->rchild[sp->parent[p]] == p)
248 sp->rchild[sp->parent[p]] = q;
250 sp->lchild[sp->parent[p]] = q;
251 sp->parent[p] = NIL;
258 struct encode_state *sp;
266 sp = (struct encode_state *) malloc(sizeof(*sp));
267 init_state(sp);
283 sp->text_buf[r + len] = *src++;
293 insert_node(sp, r - i);
299 insert_node(sp, r);
302 if (sp->match_length > len)
303 sp->match_length = len;
304 if (sp->match_length <= THRESHOLD) {
305 sp->match_length = 1; /* Not long enough match. Send one byte. */
307 code_buf[code_buf_ptr++] = sp->text_buf[r]; /* Send uncoded. */
310 code_buf[code_buf_ptr++] = (u_int8_t) sp->match_position;
312 ( ((sp->match_position >> 4) & 0xF0)
313 | (sp->match_length - (THRESHOLD + 1)) );
325 last_match_length = sp->match_length;
327 delete_node(sp, s); /* Delete old strings and */
329 sp->text_buf[s] = c; /* read new bytes */
336 sp->text_buf[s + N] = c;
343 insert_node(sp, r);
346 delete_node(sp, s);
353 insert_node(sp, r);