14 uint32_t crc_update(
const uint64_t *buf,
size_t n, uint32_t crc);
24 uint32_t read_buffer(
buffer *head,
unsigned i, uint32_t old_crc)
26 head = get_buffer(head, i);
27 return crc_update(head->data, head->count, old_crc);
30 buffer* allocate_buffer(
lp_state *state,
const unsigned *data,
unsigned count)
32 buffer *
new = malloc(
sizeof(
buffer) + count *
sizeof(uint64_t));
33 new->next = state->head;
37 memcpy(new->data, data, count *
sizeof(uint64_t));
39 for(
unsigned i = 0; i < count; i++) {
52 for (
unsigned j = 0; j < i; j++) {
54 to_free = to_free->next;
58 prev->next = to_free->next;
68 static uint32_t crc_table[256];
70 void crc_table_init(
void)
78 c = 0xedb88320UL ^ (c >> 1);
87 uint32_t crc_update(
const uint64_t *buf,
size_t n, uint32_t crc)
89 uint32_t c = crc ^ 0xffffffffUL;
94 c = crc_table[(c ^ (buf[n] >> k)) & 0xff] ^ (c >> 8);
97 return c ^ 0xffffffffUL;