mirror of https://github.com/mgba-emu/mgba.git
VFS: Allow truncating memory chunk VFiles
This commit is contained in:
parent
d0f404a6ba
commit
287ab91739
1
CHANGES
1
CHANGES
|
@ -26,6 +26,7 @@ Misc:
|
|||
- 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:
|
||||
|
|
|
@ -116,7 +116,11 @@ void _vfmExpand(struct VFileMem* vfm, size_t newSize) {
|
|||
void* oldBuf = vfm->mem;
|
||||
vfm->mem = anonymousMemoryMap(newSize);
|
||||
if (oldBuf) {
|
||||
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 _vfmUnmap(struct VFile* vf, void* memory, size_t size) {
|
|||
|
||||
void _vfmTruncate(struct VFile* vf, size_t size) {
|
||||
struct VFileMem* vfm = (struct VFileMem*) vf;
|
||||
if (size > vfm->size) {
|
||||
_vfmExpand(vfm, size);
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
void _vfmTruncateNoop(struct VFile* vf, size_t size) {
|
||||
|
|
Loading…
Reference in New Issue