mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-22 23:39:50 +00:00
Update
This commit is contained in:
parent
dde1208a5f
commit
7c7a568a2e
30
libretro.cpp
30
libretro.cpp
@ -1924,23 +1924,43 @@ static size_t serialize_size;
|
||||
size_t retro_serialize_size(void)
|
||||
{
|
||||
StateMem st;
|
||||
memset(&st, 0, sizeof(st));
|
||||
|
||||
st.data = NULL;
|
||||
st.loc = 0;
|
||||
st.len = 0;
|
||||
st.malloced = 0;
|
||||
st.initial_malloc = 0;
|
||||
|
||||
if (!MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL))
|
||||
return 0;
|
||||
|
||||
free(st.data);
|
||||
|
||||
return serialize_size = st.len;
|
||||
}
|
||||
|
||||
bool retro_serialize(void *data, size_t size)
|
||||
{
|
||||
StateMem st;
|
||||
memset(&st, 0, sizeof(st));
|
||||
st.data = (uint8_t*)data;
|
||||
st.malloced = size;
|
||||
bool ret = false;
|
||||
uint8_t *_dat = (uint8_t*)malloc(size);
|
||||
|
||||
return MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL);
|
||||
if (!_dat)
|
||||
return false;
|
||||
|
||||
/* Mednafen can realloc the buffer so we need to ensure this is safe. */
|
||||
st.data = _dat;
|
||||
st.loc = 0;
|
||||
st.len = 0;
|
||||
st.malloced = size;
|
||||
st.initial_malloc = 0;
|
||||
|
||||
ret = MDFNSS_SaveSM(&st, 0, 0, NULL, NULL, NULL);
|
||||
|
||||
memcpy(data, st.data, size);
|
||||
free(st.data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool retro_unserialize(const void *data, size_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user