Refactor value encoding in BinaryTable for improved clarity and consistency

This commit is contained in:
ImBenji
2025-10-13 15:28:20 +01:00
parent 782e3fcd94
commit a3f4b3308b

View File

@@ -719,6 +719,7 @@ void BinaryTable::setAddressTable(const std::unordered_map<int64_t, BT_Pointer>&
BT_Pointer newTableAddress = alloc(static_cast<int32_t>(buffer.size())); BT_Pointer newTableAddress = alloc(static_cast<int32_t>(buffer.size()));
setFilePosition(newTableAddress.address()); setFilePosition(newTableAddress.address());
size_t written = fwrite(buffer.data(), 1, buffer.size(), file_); size_t written = fwrite(buffer.data(), 1, buffer.size(), file_);
(void)written; // Suppress unused variable warning in release builds
if (written != buffer.size()) { if (written != buffer.size()) {
throw std::runtime_error("Failed to write complete address table"); throw std::runtime_error("Failed to write complete address table");
@@ -851,6 +852,7 @@ void BinaryTable::truncateFile(int64_t newSize) {
DEBUG_PRINTLN("DEBUG: truncateFile - resize successful"); DEBUG_PRINTLN("DEBUG: truncateFile - resize successful");
} catch (const std::exception& e) { } catch (const std::exception& e) {
DEBUG_PRINTLN("DEBUG: truncateFile - resize failed: " << e.what()); DEBUG_PRINTLN("DEBUG: truncateFile - resize failed: " << e.what());
(void)e; // Suppress unused variable warning in release builds
} }
file_ = fopen(filePath_.c_str(), "r+b"); file_ = fopen(filePath_.c_str(), "r+b");
@@ -1085,16 +1087,19 @@ void BinaryTable::debugAddressTable(const std::string& context) {
if (typeByte == 2) { // INTEGER if (typeByte == 2) { // INTEGER
int32_t value = readInt32(pointer.address() + 1); int32_t value = readInt32(pointer.address() + 1);
DEBUG_PRINTLN(" Value: " << value); DEBUG_PRINTLN(" Value: " << value);
(void)value; // Suppress unused variable warning in release builds
} else { } else {
DEBUG_PRINT(" Raw bytes: "); DEBUG_PRINT(" Raw bytes: ");
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
uint8_t byte = readByte(pointer.address() + i); uint8_t byte = readByte(pointer.address() + i);
DEBUG_PRINT(std::hex << (int)byte << " "); DEBUG_PRINT(std::hex << (int)byte << " ");
(void)byte; // Suppress unused variable warning in release builds
} }
DEBUG_PRINTLN(std::dec); DEBUG_PRINTLN(std::dec);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
DEBUG_PRINTLN(" Error reading data: " << e.what()); DEBUG_PRINTLN(" Error reading data: " << e.what());
(void)e; // Suppress unused variable warning in release builds
} }
} }
} }