fix: mcx_delchunk was not updating the byte offset of affected chunks.

This commit is contained in:
2025-08-27 11:41:31 +02:00
parent b7859d56d9
commit fad6f366b4

View File

@@ -14,6 +14,7 @@ void mcx_delchunk(u8 *restrict buf, int chunk) {
u32 *table = (u32 *)buf;
size_t bidx = (table[chunk] >> 8) * 0x1000; // compute the byte offset the chunk starts at
size_t blen = (table[chunk] & 0xFF) * 0x1000; // compute the byte length of the chunk
size_t slen = (table[chunk] & 0xFF); // acquire the sector length of the chunk
table[chunk] = 0;
table[chunk + 0x400] = time(NULL); // assign the current time to the timestamp, for correctness NOTE: might need to zero-out instead
@@ -23,8 +24,10 @@ void mcx_delchunk(u8 *restrict buf, int chunk) {
// count the amount of bytes that we must move
blen = 0;
for (chunk++; chunk < 0x400; chunk++)
for (chunk++; chunk < 0x400; chunk++) {
blen += table[chunk] & 0xFF * 0x1000;
table[chunk] -= htobe32(slen << 8);
}
memmove(head, tail, blen);
}