Fix weird types and other legacy leftovers

This commit is contained in:
Alcaro 2016-09-18 18:09:16 +02:00
parent 78e0e817dd
commit 62ecce7644
2 changed files with 8 additions and 10 deletions

View File

@ -20,7 +20,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
static const unsigned long crc_table[256] = {
#include <stdint.h>
static const uint32_t crc_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
@ -75,18 +77,14 @@ static const unsigned long crc_table[256] = {
0x2d02ef8dL
};
#define DO1_CRC32(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO1_CRC32(buf) crc = crc_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
#define DO2_CRC32(buf) DO1_CRC32(buf); DO1_CRC32(buf);
#define DO4_CRC32(buf) DO2_CRC32(buf); DO2_CRC32(buf);
#define DO8_CRC32(buf) DO4_CRC32(buf); DO4_CRC32(buf);
unsigned long encoding_crc32(
unsigned long crc, const unsigned char *buf, unsigned int len)
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len)
{
if (buf == 0)
return 0L;
crc = crc ^ 0xffffffffL;
crc = crc ^ 0xffffffff;
while (len >= 8)
{
@ -101,5 +99,5 @@ unsigned long encoding_crc32(
} while (--len);
}
return crc ^ 0xffffffffL;
return crc ^ 0xffffffff;
}

View File

@ -26,6 +26,6 @@
#include <stdint.h>
#include <stddef.h>
unsigned long encoding_crc32(unsigned long crc, const unsigned char *buf, unsigned int len);
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len);
#endif