diff options
author | Nebuleon Fumika | 2013-02-01 00:33:30 -0500 |
---|---|---|
committer | Nebuleon Fumika | 2013-02-01 00:33:30 -0500 |
commit | f385752705de73b04cbbda735a71f14c19e241a6 (patch) | |
tree | 59aca906a8c3fcbaae402d503e7c6b34643e0199 /source/snapshot.cpp | |
parent | f0fab191e48f165c551980d724bba2f26a764795 (diff) | |
download | snesemu-f385752705de73b04cbbda735a71f14c19e241a6.tar.gz snesemu-f385752705de73b04cbbda735a71f14c19e241a6.tar.bz2 snesemu-f385752705de73b04cbbda735a71f14c19e241a6.zip |
memcpy vs memmove: memmove correctly handles overlapping source and destination memory buffers, but is slower than memcpy in many implementations. When memory buffers don't overlap, memcpy may be more efficient.
The DS2 SDK is such an implementation, so change many memmoves into memcpys.
Diffstat (limited to 'source/snapshot.cpp')
-rw-r--r-- | source/snapshot.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/snapshot.cpp b/source/snapshot.cpp index ad9b131..c414dc2 100644 --- a/source/snapshot.cpp +++ b/source/snapshot.cpp @@ -1036,7 +1036,8 @@ void FreezeStruct (STREAM stream, char *name, void *base, FreezeData *fields, } break; case uint8_ARRAY_V: - memmove (ptr, (uint8 *) base + fields [i].offset, fields [i].size); + // memmove converted: Different mallocs [Neb] + memcpy (ptr, (uint8 *) base + fields [i].offset, fields [i].size); ptr += fields [i].size; break; case uint16_ARRAY_V: @@ -1139,7 +1140,8 @@ int UnfreezeStruct (STREAM stream, char *name, void *base, FreezeData *fields, } break; case uint8_ARRAY_V: - memmove ((uint8 *) base + fields [i].offset, ptr, fields [i].size); + // memmove converted: Different mallocs [Neb] + memcpy ((uint8 *) base + fields [i].offset, ptr, fields [i].size); ptr += fields [i].size; break; case uint16_ARRAY_V: @@ -1264,6 +1266,7 @@ void UnfreezeStructFromCopy (void *base, FreezeData *fields, int num_fields, uin } break; case uint8_ARRAY_V: + // memmove required: Source could point within dest [Neb] memmove ((uint8 *) base + fields [i].offset, ptr, fields [i].size); ptr += fields [i].size; break; @@ -1581,7 +1584,8 @@ bool8 S9xUnfreezeZSNES (const char *filename) APU.Timer [1] = t [45]; APU.Timer [2] = t [46]; - memmove (APU.ExtraRAM, &t [48], 64); + // memmove converted: Different mallocs [Neb] + memcpy (APU.ExtraRAM, &t [48], 64); // Internal ZSNES sound DSP state fread (t, 1, 1068, fs); @@ -1657,7 +1661,9 @@ bool8 S9xUnfreezeZSNES (const char *filename) SA1.Registers.PC = READ_DWORD (&t [636]); SA1.Registers.P.W = t [620] | (t [624] << 8); - memmove (&Memory.FillRAM [0x3000], t + 692, 2 * 1024); + // memmove converted: Different mallocs [Neb] + // DS2 DMA notes: This code path is not used [Neb] + memcpy (&Memory.FillRAM [0x3000], t + 692, 2 * 1024); fread (::SRAM, 1, 64 * 1024, fs); fseek (fs, 64 * 1024, SEEK_CUR); |