all repos — mgba @ 287ab91739e5780834066f497db9b78755436912

mGBA Game Boy Advance Emulator

VFS: Allow truncating memory chunk VFiles
Jeffrey Pfau jeffrey@endrift.com
Fri, 21 Oct 2016 23:18:18 -0700
commit

287ab91739e5780834066f497db9b78755436912

parent

d0f404a6ba7c0588d3a3c7b43225a32f4fc2d8a6

2 files changed, 7 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -26,6 +26,7 @@ - VFS: Call msync when syncing mapped data

- GBA Video, GB Video: Colors are now fully scaled - PSP2: Improved controller rumble - GB, GBA: Prevent loading null ROMs + - VFS: Allow truncating memory chunk VFiles 0.5.1: (2016-10-05) Bugfixes:
M src/util/vfs/vfs-mem.csrc/util/vfs/vfs-mem.c

@@ -116,7 +116,11 @@ void _vfmExpand(struct VFileMem* vfm, size_t newSize) {

void* oldBuf = vfm->mem; vfm->mem = anonymousMemoryMap(newSize); if (oldBuf) { - memcpy(vfm->mem, oldBuf, vfm->size); + if (newSize < vfm->size) { + memcpy(vfm->mem, oldBuf, newSize); + } else { + memcpy(vfm->mem, oldBuf, vfm->size); + } mappedMemoryFree(oldBuf, vfm->size); } vfm->size = newSize;

@@ -270,11 +274,7 @@ }

void _vfmTruncate(struct VFile* vf, size_t size) { struct VFileMem* vfm = (struct VFileMem*) vf; - if (size > vfm->size) { - _vfmExpand(vfm, size); - } else { - // TODO - } + _vfmExpand(vfm, size); } void _vfmTruncateNoop(struct VFile* vf, size_t size) {