mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 16:13:40 +00:00
Well I didn't expect bugs here. How long has that math been wrong?
This commit is contained in:
parent
53b96c19af
commit
65a97a6a87
4
rewind.c
4
rewind.c
@ -95,7 +95,7 @@ size_t state_manager_raw_maxsize(size_t uncomp)
|
|||||||
/* bytes covered by a compressed block */
|
/* bytes covered by a compressed block */
|
||||||
const int maxcblkcover = UINT16_MAX * sizeof(uint16_t);
|
const int maxcblkcover = UINT16_MAX * sizeof(uint16_t);
|
||||||
/* uncompressed size, rounded to 16 bits */
|
/* 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 */
|
/* number of blocks */
|
||||||
size_t maxcblks = (uncomp + maxcblkcover - 1) / maxcblkcover;
|
size_t maxcblks = (uncomp + maxcblkcover - 1) / maxcblkcover;
|
||||||
return uncomp16 + maxcblks * sizeof(uint16_t) * 2 /* two u16 overhead per block */ + sizeof(uint16_t) *
|
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)
|
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);
|
uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user