X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fq.c;h=9f7ce2c5384e6e9f4ceb7ebedfd1d323845876a2;hp=8971616a617df96619035e39f20ffbd63209334a;hb=c63b2bf21dc1df9a736f0b4c08f6cba828cdab92;hpb=2ddfa640af28b592ecf4295f0b1b7b43c923f707 diff --git a/lib/q.c b/lib/q.c index 8971616..9f7ce2c 100644 --- a/lib/q.c +++ b/lib/q.c @@ -688,6 +688,18 @@ unsigned int crc32_add_string(unsigned int checksum, const char*s) } return checksum; } +unsigned int crc32_add_bytes(unsigned int checksum, const void*_s, int len) +{ + unsigned char*s = (unsigned char*)_s; + crc32_init(); + if(!s || !len) + return checksum; + do { + checksum = checksum>>8 ^ crc32[(*s^checksum)&0xff]; + s++; + } while(--len); + return checksum; +} unsigned int string_hash(const string_t*str) { @@ -1340,10 +1352,12 @@ void mtf_increase(mtf_t*m, const void*key) while(item) { if(m->type->equals(item->key, key)) { item->num++; - if(last) last->next = item->next; - else m->first = item->next; - item->next = m->first; - m->first = item; + if(item->num>m->first->num) { + if(last) last->next = item->next; + else m->first = item->next; + item->next = m->first; + m->first = item; + } return; } last = item;