Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool retro_serialize(void *data, size_t size)
- {
- /* it seems that mednafen can realloc pointers sent to it?
- since we don't know the disposition of void* data (is it safe to realloc?) we have to manage a new buffer here */
- StateMem st;
- memset(&st, 0, sizeof(st));
- st.data = (uint8_t*)malloc(size);
- st.malloced = size;
- bool ret = MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL);
- /* there are still some errors with the save states, the size seems to change on some games for now just log when this happens */
- if (st.len != size)
- log_cb(RETRO_LOG_WARN, "warning, save state size has changed\n");
- if( st.len > size) {
- log_cb(RETRO_LOG_ERROR, "ERROR: save state size inflated. This is forbidden. Can't serialize.\n");
- return false;
- }
- memcpy(data,st.data,size);
- free(st.data);
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement