mirror of https://github.com/mgba-emu/mgba.git
Util: Patch input should be const
This commit is contained in:
parent
90edf4d1a0
commit
e9d83bafe3
|
@ -9,7 +9,7 @@
|
|||
#include "util/vfs.h"
|
||||
|
||||
static size_t _IPSOutputSize(struct Patch* patch, size_t inSize);
|
||||
static bool _IPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize);
|
||||
static bool _IPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize);
|
||||
|
||||
bool loadPatchIPS(struct Patch* patch) {
|
||||
patch->vf->seek(patch->vf, 0, SEEK_SET);
|
||||
|
@ -43,7 +43,7 @@ size_t _IPSOutputSize(struct Patch* patch, size_t inSize) {
|
|||
return 16 * 1024 * 1024; // IPS patches can grow up to 16MiB, but not beyond
|
||||
}
|
||||
|
||||
bool _IPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize) {
|
||||
bool _IPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize) {
|
||||
if (patch->vf->seek(patch->vf, 5, SEEK_SET) != 5) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ enum {
|
|||
|
||||
static size_t _UPSOutputSize(struct Patch* patch, size_t inSize);
|
||||
|
||||
static bool _UPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize);
|
||||
static bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize);
|
||||
static bool _UPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize);
|
||||
static bool _BPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize);
|
||||
|
||||
static size_t _decodeLength(struct VFile* vf);
|
||||
|
||||
|
@ -64,7 +64,7 @@ size_t _UPSOutputSize(struct Patch* patch, size_t inSize) {
|
|||
return _decodeLength(patch->vf);
|
||||
}
|
||||
|
||||
bool _UPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize) {
|
||||
bool _UPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize) {
|
||||
// TODO: Input checksum
|
||||
|
||||
size_t filesize = patch->vf->size(patch->vf);
|
||||
|
@ -109,7 +109,7 @@ bool _UPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize) {
|
||||
bool _BPSApplyPatch(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize) {
|
||||
patch->vf->seek(patch->vf, IN_CHECKSUM, SEEK_END);
|
||||
uint32_t expectedInChecksum;
|
||||
uint32_t expectedOutChecksum;
|
||||
|
@ -139,7 +139,7 @@ bool _BPSApplyPatch(struct Patch* patch, void* in, size_t inSize, void* out, siz
|
|||
ssize_t readTargetLocation = 0;
|
||||
size_t readOffset;
|
||||
uint8_t* writeBuffer = out;
|
||||
uint8_t* readBuffer = in;
|
||||
const uint8_t* readBuffer = in;
|
||||
while (patch->vf->seek(patch->vf, 0, SEEK_CUR) < filesize + IN_CHECKSUM) {
|
||||
size_t command = _decodeLength(patch->vf);
|
||||
size_t length = (command >> 2) + 1;
|
||||
|
|
|
@ -14,7 +14,7 @@ struct Patch {
|
|||
struct VFile* vf;
|
||||
|
||||
size_t (*outputSize)(struct Patch* patch, size_t inSize);
|
||||
bool (*applyPatch)(struct Patch* patch, void* in, size_t inSize, void* out, size_t outSize);
|
||||
bool (*applyPatch)(struct Patch* patch, const void* in, size_t inSize, void* out, size_t outSize);
|
||||
};
|
||||
|
||||
bool loadPatch(struct VFile* vf, struct Patch* patch);
|
||||
|
|
Loading…
Reference in New Issue