X-Git-Url: http://dolda2000.com/gitweb/?p=vcfs.git;a=blobdiff_plain;f=store.c;h=b8077d34a928b361d0011f35f51bec0ece6f2c2a;hp=87275123f98283c32a8b805c0501209ffc6990d1;hb=efe8eeebe84e835d36717a0ea3085d9c8084aafb;hpb=d5cf535197d5090554453b6357867d782f0d1484 diff --git a/store.c b/store.c index 8727512..b8077d3 100644 --- a/store.c +++ b/store.c @@ -22,7 +22,7 @@ static ssize_t cacheget(struct store *st, struct addr *a, void *buf, size_t len) { int he, i; - he = a->hash[0] + ((a->hash[1] & 0x0f) << 8); + he = a->hash[0] | ((a->hash[1] & 0x0f) << 8); for(i = 0; i < 4; i++) { if(!addrcmp(&st->cache[he * 4 + i].a, a)) break; @@ -39,7 +39,7 @@ static void cacheput(struct store *st, struct addr *a, const void *data, ssize_t int he, i; struct storecache tmp; - he = a->hash[0] + ((a->hash[1] & 0x0f) << 8); + he = a->hash[0] | ((a->hash[1] & 0x0f) << 8); for(i = 0; i < 4; i++) { if(!addrcmp(&st->cache[he * 4 + i].a, a)) break; @@ -48,13 +48,13 @@ static void cacheput(struct store *st, struct addr *a, const void *data, ssize_t return; if(i < 4) { tmp = st->cache[he * 4 + i]; - memmove(&st->cache[he * 4 + 1], &st->cache[he * 4], i); + memmove(&st->cache[he * 4 + 1], &st->cache[he * 4], i * sizeof(struct storecache)); st->cache[he * 4] = tmp; return; } if(st->cache[he * 4 + 3].data != NULL) free(st->cache[he * 4 + 3].data); - memmove(&st->cache[he * 4 + 1], &st->cache[he * 4], 3); + memmove(&st->cache[he * 4 + 1], &st->cache[he * 4], 3 * sizeof(struct storecache)); st->cache[he * 4].a = *a; if(len > 0) st->cache[he * 4].data = memcpy(malloc(len), data, len);