Changeset 10596:54f9c123f145 in orange for source/include/crc.h


Ignore:
Timestamp:
03/21/12 14:25:16 (2 years ago)
Author:
Matija Polajnar <matija.polajnar@…>
Branch:
default
Message:

Urgent bugfix: Refactor CRC variables from unsigned long to unsigned int to make it work properly on 64-bit machines (with 64-bit Python and libraries). Fixes #1146.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/include/crc.h

    r10591 r10596  
    2222#define __CRC_H 
    2323 
    24 extern unsigned long crc_table[256]; 
     24extern unsigned int crc_table[256]; 
    2525 
    2626#define INIT_CRC(x) (x) = 0xffffffff 
     
    3232      crc = (crc >> 8) ^ crc_table[(crc & 0xFF) ^ *(b++)]); \ 
    3333 
    34 inline void add_CRC(const int data, unsigned long &crc) 
     34inline void add_CRC(const int data, unsigned int &crc) 
    3535{ ADD_CRC } 
    3636 
    37 inline void add_CRC(const unsigned long data, unsigned long &crc) 
     37inline void add_CRC(const unsigned long data, unsigned int &crc) 
    3838{ ADD_CRC } 
    3939 
    40 inline void add_CRC(const float data, unsigned long &crc) 
     40inline void add_CRC(const float data, unsigned int &crc) 
    4141{ ADD_CRC } 
    4242 
    43 inline void add_CRC(const unsigned char c, unsigned long &crc) 
     43inline void add_CRC(const unsigned char c, unsigned int &crc) 
    4444{ crc = (crc >> 8) ^ crc_table[(crc & 0xFF) ^ c]; } 
    4545 
    46 inline void add_CRC(const char *c, unsigned long &crc) 
     46inline void add_CRC(const char *c, unsigned int &crc) 
    4747{ 
    4848  for(; *c; add_CRC((unsigned char)*c++, crc)); 
Note: See TracChangeset for help on using the changeset viewer.