diff --git a/rewind.c b/rewind.c index a02b6f42e6..441496e76f 100644 --- a/rewind.c +++ b/rewind.c @@ -22,8 +22,6 @@ #include #include -//#include - struct state_manager { uint64_t *buffer; @@ -125,7 +123,6 @@ static void reassign_bottom(state_manager_t *state) static void generate_delta(state_manager_t *state, const void *data) { - //unsigned patch_size = 0; bool crossed = false; const uint32_t *old_state = state->tmp_state; const uint32_t *new_state = data; @@ -138,11 +135,12 @@ static void generate_delta(state_manager_t *state, const void *data) { uint64_t xor = old_state[i] ^ new_state[i]; - // If the data differs (xor != 0), we push that xor on the stack with index and xor. This can be reversed by reapplying the xor. - // This, if states don't really differ much, we'll save lots of space :) Hopefully this will work really well with save states. + // If the data differs (xor != 0), we push that xor on the stack with index and xor. + // This can be reversed by reapplying the xor. + // This, if states don't really differ much, we'll save lots of space :) + // Hopefully this will work really well with save states. if (xor) { - //patch_size++; state->buffer[state->top_ptr] = (i << 32) | xor; state->top_ptr = (state->top_ptr + 1) % state->buf_size; @@ -153,8 +151,6 @@ static void generate_delta(state_manager_t *state, const void *data) if (crossed) reassign_bottom(state); - - //fprintf(stderr, "DELTA SIZE: %u, ORIG SIZE: %u\n", (unsigned)patch_size << 3, (unsigned)state->state_size << 2); } bool state_manager_push(state_manager_t *state, const void *data) diff --git a/ssnes.c b/ssnes.c index 1d8de41a13..4b262ade1f 100644 --- a/ssnes.c +++ b/ssnes.c @@ -1013,7 +1013,7 @@ static void init_rewind(void) if (g_settings.rewind_enable) { size_t serial_size = psnes_serialize_size(); - g_extern.state_buf = malloc((serial_size + 3) & ~3); // Make sure we allocate at least 4-byte multiple. + g_extern.state_buf = calloc(1, (serial_size + 3) & ~3); // Make sure we allocate at least 4-byte multiple. psnes_serialize(g_extern.state_buf, serial_size); SSNES_LOG("Initing rewind buffer with size: %u MB\n", (unsigned)g_settings.rewind_buffer_size / 1000000); g_extern.state_manager = state_manager_new((serial_size + 3) & ~3, g_settings.rewind_buffer_size, g_extern.state_buf);