]> Sergey Matveev's repositories - nnn.git/commitdiff
Use static variables for crc8fast
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 25 Apr 2018 19:06:51 +0000 (00:36 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 25 Apr 2018 19:06:51 +0000 (00:36 +0530)
nnn.c

diff --git a/nnn.c b/nnn.c
index e1f7cb5bd6d7f24950b10398ba72a1db1acc6ef5..c8da7531e3f485bac920c23ca66164251eb13cf6 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -354,13 +354,11 @@ crc8init()
 static uchar
 crc8fast(uchar const message[], size_t n)
 {
-    uchar data;
-    uchar remainder = 0;
-    size_t byte;
-
+    static uchar data, remainder;
+    static size_t byte;
 
     /* 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));
         remainder = crc8table[data] ^ (remainder << 8);
     }