From 65a97a6a8769212e45e010a543dd360ab578d539 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Wed, 4 Nov 2015 20:18:09 +0100 Subject: [PATCH] Well I didn't expect bugs here. How long has that math been wrong? --- rewind.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rewind.c b/rewind.c index 8dbcce41d9..31d35ddd5c 100644 --- a/rewind.c +++ b/rewind.c @@ -95,7 +95,7 @@ size_t state_manager_raw_maxsize(size_t uncomp) /* bytes covered by a compressed block */ const int maxcblkcover = UINT16_MAX * sizeof(uint16_t); /* uncompressed size, rounded to 16 bits */ - size_t uncomp16 = (uncomp + sizeof(uint16_t) - 1) & ~sizeof(uint16_t); + size_t uncomp16 = (uncomp + sizeof(uint16_t) - 1) & -sizeof(uint16_t); /* number of blocks */ size_t maxcblks = (uncomp + maxcblkcover - 1) / maxcblkcover; return uncomp16 + maxcblks * sizeof(uint16_t) * 2 /* two u16 overhead per block */ + sizeof(uint16_t) * @@ -104,7 +104,7 @@ size_t state_manager_raw_maxsize(size_t uncomp) void *state_manager_raw_alloc(size_t len, uint16_t uniq) { - size_t len16 = (len + sizeof(uint16_t) - 1) & ~sizeof(uint16_t); + size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1);