henesyinit from p9fd787fda5 years agoHistory
40 lines · 604 B · C
RawDownload
#include <u.h>#include <libc.h>#include <flate.h> ulong*mkcrctab(ulong poly){	ulong *crctab;	ulong crc;	int i, j; 	crctab = malloc(256 * sizeof(ulong));	if(crctab == nil)		return nil; 	for(i = 0; i < 256; i++){		crc = i;		for(j = 0; j < 8; j++){			if(crc & 1)				crc = (crc >> 1) ^ poly;			else				crc >>= 1;		}		crctab[i] = crc;	}	return crctab;} ulongblockcrc(ulong *crctab, ulong crc, void *vbuf, int n){	uchar *buf, *ebuf; 	crc ^= 0xffffffff;	buf = vbuf;	ebuf = buf + n;	while(buf < ebuf)		crc = crctab[(crc & 0xff) ^ *buf++] ^ (crc >> 8);	return crc ^ 0xffffffff;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t