mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Refactor secondary DDT table creation logic to check for cached entries
This commit is contained in:
@@ -1224,9 +1224,9 @@ void set_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sectorAddress, bool
|
||||
}
|
||||
|
||||
// Step 5: Check if the specified block already has an existing secondary level table
|
||||
createNewTable = secondaryDdtOffset == 0;
|
||||
createNewTable = ctx->cachedSecondaryDdtSmall == NULL && ctx->cachedSecondaryDdtBig == NULL;
|
||||
|
||||
if(!createNewTable)
|
||||
if(!createNewTable && secondaryDdtOffset != 0)
|
||||
{
|
||||
// Load existing table
|
||||
fseek(ctx->imageStream, secondaryDdtOffset, SEEK_SET);
|
||||
@@ -1281,7 +1281,8 @@ void set_ddt_multi_level_v2(aaruformatContext *ctx, uint64_t sectorAddress, bool
|
||||
|
||||
ctx->cachedDdtOffset = secondaryDdtOffset;
|
||||
}
|
||||
else
|
||||
|
||||
if(createNewTable)
|
||||
{
|
||||
// Create a new empty table
|
||||
size_t tableSize = ctx->userDataDdtHeader.sizeType == SmallDdtSizeType ? itemsPerDdtEntry * sizeof(uint16_t)
|
||||
|
||||
Reference in New Issue
Block a user