MCPcopy Create free account
hub / github.com/F-Stack/f-stack / Pred1Compress

Function Pred1Compress

freebsd/netgraph/ng_pred1.c:583–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581 */
582
583static int
584Pred1Compress(node_p node, u_char *source, u_char *dest, int len)
585{
586 const priv_p priv = NG_NODE_PRIVATE(node);
587 int i;
588 u_char flags;
589 u_char *flagdest, *orgdest;
590
591 orgdest = dest;
592 while (len) {
593 flagdest = dest++;
594 flags = 0; /* All guesses are wrong initially. */
595 for (i = 0; i < 8 && len; i++) {
596 if (priv->GuessTable[priv->Hash] == *source)
597 /* Guess was right - don't output. */
598 flags |= (1 << i);
599 else {
600 /* Guess wrong, output char. */
601 priv->GuessTable[priv->Hash] = *source;
602 *dest++ = *source;
603 }
604 HASH(*source++);
605 len--;
606 }
607 *flagdest = flags;
608 }
609 return (dest - orgdest);
610}
611
612/*
613 * Pred1Decompress()

Callers 1

ng_pred1_compressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected