mirror of https://github.com/mgba-emu/mgba.git
Core: Cleanup (I wish I had reviewers sometimes)
This commit is contained in:
parent
a052feda88
commit
cfc90a3b67
|
@ -305,20 +305,20 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
|
||||||
size_t stateSize = core->stateSize(core);
|
size_t stateSize = core->stateSize(core);
|
||||||
|
|
||||||
if (flags & SAVESTATE_METADATA) {
|
if (flags & SAVESTATE_METADATA) {
|
||||||
uint64_t creationUsec;
|
uint64_t* creationUsec = malloc(sizeof(*creationUsec));
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
if (!gettimeofday(&tv, 0)) {
|
if (!gettimeofday(&tv, 0)) {
|
||||||
uint64_t usec = tv.tv_usec;
|
uint64_t usec = tv.tv_usec;
|
||||||
usec += tv.tv_sec * 1000000LL;
|
usec += tv.tv_sec * 1000000LL;
|
||||||
STORE_64LE(usec, 0, &creationUsec);
|
STORE_64LE(usec, 0, creationUsec);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
if (timespec_get(&ts, TIME_UTC)) {
|
if (timespec_get(&ts, TIME_UTC)) {
|
||||||
uint64_t usec = ts.tv_nsec / 1000;
|
uint64_t usec = ts.tv_nsec / 1000;
|
||||||
usec += ts.tv_sec * 1000000LL;
|
usec += ts.tv_sec * 1000000LL;
|
||||||
STORE_64LE(usec, 0, &creationUsec);
|
STORE_64LE(usec, 0, creationUsec);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
@ -326,11 +326,10 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mStateExtdataItem item = {
|
struct mStateExtdataItem item = {
|
||||||
.size = sizeof(creationUsec),
|
.size = sizeof(*creationUsec),
|
||||||
.data = malloc(sizeof(creationUsec)),
|
.data = creationUsec,
|
||||||
.clean = free
|
.clean = free
|
||||||
};
|
};
|
||||||
*(uint64_t*) item.data = creationUsec;
|
|
||||||
mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item);
|
mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue