Revert rewind.c

This commit is contained in:
twinaphex 2015-09-15 19:02:39 +02:00
parent 872314f910
commit 557347fba6

View File

@ -16,7 +16,6 @@
*/
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -27,12 +26,12 @@
#include "rewind.h"
#include "performance.h"
#ifndef UINT_FAST16_MAX
#define UINT_FAST16_MAX 0xffff
#ifndef UINT16_MAX
#define UINT16_MAX 0xffff
#endif
#ifndef UINT_LEAST32_MAX
#define UINT_LEAST32_MAX 0xffffffffu
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffffu
#endif
#undef CPU_X86
@ -68,7 +67,7 @@ size thisstart;
size_t state_manager_raw_maxsize(size_t uncomp)
{
/* bytes covered by a compressed block */
const int maxcblkcover = UINT_FAST16_MAX * sizeof(uint16_t);
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);
/* number of blocks */
@ -246,13 +245,15 @@ size_t state_manager_raw_compress(const void *src,
new16 += skip;
num16s -= skip;
if (skip > UINT_FAST16_MAX)
if (skip > UINT16_MAX)
{
/* This will make it scan the entire thing again,
* but it only hits on 8GB unchanged data anyways,
* and if you're doing that, you've got bigger problems. */
if (skip > UINT_LEAST32_MAX)
skip = UINT_LEAST32_MAX;
if (skip > UINT32_MAX)
{
/* This will make it scan the entire thing again,
* but it only hits on 8GB unchanged data anyways,
* and if you're doing that, you've got bigger problems. */
skip = UINT32_MAX;
}
*compressed16++ = 0;
*compressed16++ = skip;
*compressed16++ = skip >> 16;
@ -261,8 +262,8 @@ size_t state_manager_raw_compress(const void *src,
}
changed = find_same(old16, new16);
if (changed > UINT_FAST16_MAX)
changed = UINT_FAST16_MAX;
if (changed > UINT16_MAX)
changed = UINT16_MAX;
*compressed16++ = changed;
*compressed16++ = skip;