all repos — mgba @ cfc90a3b67d42d6019ddd44742068af6df3f54c8

mGBA Game Boy Advance Emulator

Core: Cleanup (I wish I had reviewers sometimes)
Vicki Pfau vi@endrift.com
Mon, 03 Sep 2018 13:13:15 -0700
commit

cfc90a3b67d42d6019ddd44742068af6df3f54c8

parent

a052feda88017f2ec5e3f38f78b1f835a78669bf

1 files changed, 5 insertions(+), 6 deletions(-)

jump to
M src/core/serialize.csrc/core/serialize.c

@@ -305,20 +305,20 @@ mStateExtdataInit(&extdata);

size_t stateSize = core->stateSize(core); if (flags & SAVESTATE_METADATA) { - uint64_t creationUsec; + uint64_t* creationUsec = malloc(sizeof(*creationUsec)); #ifndef _MSC_VER struct timeval tv; if (!gettimeofday(&tv, 0)) { uint64_t usec = tv.tv_usec; usec += tv.tv_sec * 1000000LL; - STORE_64LE(usec, 0, &creationUsec); + STORE_64LE(usec, 0, creationUsec); } #else struct timespec ts; if (timespec_get(&ts, TIME_UTC)) { uint64_t usec = ts.tv_nsec / 1000; usec += ts.tv_sec * 1000000LL; - STORE_64LE(usec, 0, &creationUsec); + STORE_64LE(usec, 0, creationUsec); } #endif else {

@@ -326,11 +326,10 @@ creationUsec = 0;

} struct mStateExtdataItem item = { - .size = sizeof(creationUsec), - .data = malloc(sizeof(creationUsec)), + .size = sizeof(*creationUsec), + .data = creationUsec, .clean = free }; - *(uint64_t*) item.data = creationUsec; mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item); }