Improve byte_data const correctness

This commit is contained in:
topjohnwu
2023-06-03 03:16:03 -07:00
parent 57afae3425
commit 2a654e5d7f
17 changed files with 186 additions and 161 deletions
+4 -4
View File
@@ -40,21 +40,21 @@ static int skip_encryption_pattern(const char *s) {
}
static bool remove_pattern(byte_data &data, int(*pattern_skip)(const char *)) {
char *src = reinterpret_cast<char *>(data.buf);
size_t orig_sz = data.sz;
char *src = reinterpret_cast<char *>(data.buf());
size_t orig_sz = data.sz();
int write = 0;
int read = 0;
while (read < orig_sz) {
if (int skip = pattern_skip(src + read); skip > 0) {
fprintf(stderr, "Remove pattern [%.*s]\n", skip, src + read);
data.sz -= skip;
data.sz() -= skip;
read += skip;
} else {
src[write++] = src[read++];
}
}
memset(src + write, 0, orig_sz - write);
return data.sz != orig_sz;
return data.sz() != orig_sz;
}
bool patch_verity(byte_data &data) {