Util: Patch input should be const
Jeffrey Pfau jeffrey@endrift.com
Sun, 28 Aug 2016 20:36:52 -0700
3 files changed,
8 insertions(+),
8 deletions(-)
M
src/util/patch-ips.c
→
src/util/patch-ips.c
@@ -9,7 +9,7 @@ #include "util/patch.h"
#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 @@ UNUSED(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; }
M
src/util/patch-ups.c
→
src/util/patch-ups.c
@@ -17,8 +17,8 @@ };
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 @@ }
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 @@ }
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 @@ ssize_t readSourceLocation = 0;
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;
M
src/util/patch.h
→
src/util/patch.h
@@ -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);