mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Use static variables for crc8fast
This commit is contained in:
parent
3e34272324
commit
02a2551a17
8
nnn.c
8
nnn.c
|
@ -354,13 +354,11 @@ crc8init()
|
||||||
static uchar
|
static uchar
|
||||||
crc8fast(uchar const message[], size_t n)
|
crc8fast(uchar const message[], size_t n)
|
||||||
{
|
{
|
||||||
uchar data;
|
static uchar data, remainder;
|
||||||
uchar remainder = 0;
|
static size_t byte;
|
||||||
size_t byte;
|
|
||||||
|
|
||||||
|
|
||||||
/* Divide the message by the polynomial, a byte at a time */
|
/* Divide the message by the polynomial, a byte at a time */
|
||||||
for (byte = 0; byte < n; ++byte) {
|
for (remainder = byte = 0; byte < n; ++byte) {
|
||||||
data = message[byte] ^ (remainder >> (WIDTH - 8));
|
data = message[byte] ^ (remainder >> (WIDTH - 8));
|
||||||
remainder = crc8table[data] ^ (remainder << 8);
|
remainder = crc8table[data] ^ (remainder << 8);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue