Ignore:
Timestamp:
May 6, 2011, 7:47:13 PM (9 years ago)
Author:
Sam Hocevar
Message:

tool: compute and display SPEC item CRCs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/crc.cpp

    r555 r585  
    1515#include "crc.h"
    1616
    17 uint16_t calc_crc(uint8_t *buf, int len)
     17uint16_t calc_crc(void *buf, size_t len)
    1818{
    19   uint8_t c1=0,c2=0;
    20   while (len)
    21   {
    22     len--;
    23     c1+=*buf;
    24     c2+=c1;
    25     buf++;
    26   }
    27   return (c2<<8)|c1;
     19    uint8_t *data = (uint8_t *)buf;
     20    uint8_t c1 = 0, c2 = 0;
     21
     22    while (len--)
     23        c2 += (c1 += *data++);
     24
     25    return (c2 << 8) | c1;
    2826}
    2927
Note: See TracChangeset for help on using the changeset viewer.