Rename sectorPrefix to sector_prefix for consistency

This commit is contained in:
2025-10-03 19:53:16 +01:00
parent cc56c2cc34
commit 1feb82a678
6 changed files with 37 additions and 40 deletions

View File

@@ -156,12 +156,12 @@ typedef struct aaruformatContext
AaruHeaderV2 header; ///< Parsed container header (v2).
/* Optical auxiliary buffers (NULL if not present) */
uint8_t *sectorPrefix; ///< Raw per-sector prefix (e.g., sync+header) uncorrected.
uint8_t *sector_prefix; ///< Raw per-sector prefix (e.g., sync+header) uncorrected.
uint8_t *sectorPrefixCorrected; ///< Corrected variant (post error correction) if stored.
uint8_t *sectorSuffix; ///< Raw per-sector suffix (EDC/ECC) uncorrected.
uint8_t *sectorSuffixCorrected; ///< Corrected suffix if stored separately.
uint8_t *sectorSubchannel; ///< Raw 96-byte subchannel (if captured).
uint8_t *mode2_subheaders; ///< MODE2 Form1/Form2 8-byte subheaders (concatenated).
uint8_t *mode2_subheaders; ///< MODE2 Form1/Form2 8-byte subheaders (concatenated).
uint8_t shift; ///< Legacy overall shift (deprecated by data_shift/table_shift).
bool inMemoryDdt; ///< True if primary (and possibly secondary) DDT loaded.
@@ -232,11 +232,10 @@ typedef struct aaruformatContext
uint8_t currentTrackType; ///< Current track type (when writing optical images with tracks, needed for block
///< compression type).
bool writingLong; ///< True if writing long sectors
uint8_t *sectorPrefixBuffer; ///< Buffer for storing sector prefixes when writing optical images
uint8_t *sectorSuffixBuffer; ///< Buffer for storing sector suffixes when writing optical images
size_t sectorPrefixBufferLength; ///< Length of sectorPrefixBuffer
size_t sector_prefix_length; ///< Length of sectorPrefixBuffer
size_t sectorSuffixBufferLength; ///< Length of sectorSuffixBuffer
size_t sectorPrefixBufferOffset; ///< Current position in sectorPrefixBuffer
size_t sector_prefix_offset; ///< Current position in sectorPrefixBuffer
size_t sectorSuffixBufferOffset; ///< Current position in sectorSuffixBuffer
} aaruformatContext;

View File

@@ -304,7 +304,7 @@ int32_t process_data_block(aaruformatContext *ctx, IndexEntry *entry)
case CdSectorPrefixCorrected:
if(entry->dataType == CdSectorPrefixCorrected) { ctx->sectorPrefixCorrected = data; }
else
ctx->sectorPrefix = data;
ctx->sector_prefix = data;
ctx->readableSectorTags[CdSectorSync] = true;
ctx->readableSectorTags[CdSectorHeader] = true;

View File

@@ -874,8 +874,8 @@ int aaruf_close(void *context)
ctx->indexEntries = NULL;
}
free(ctx->sectorPrefix);
ctx->sectorPrefix = NULL;
free(ctx->sector_prefix);
ctx->sector_prefix = NULL;
free(ctx->sectorPrefixCorrected);
ctx->sectorPrefixCorrected = NULL;
free(ctx->sectorSuffix);

View File

@@ -827,7 +827,7 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
TRACE("Exiting aaruf_read_sector_long() = AARUF_ERROR_BUFFER_TOO_SMALL");
return AARUF_ERROR_BUFFER_TOO_SMALL;
}
if((ctx->sectorSuffix == NULL || ctx->sectorPrefix == NULL) &&
if((ctx->sectorSuffix == NULL || ctx->sector_prefix == NULL) &&
(ctx->sectorSuffixCorrected == NULL || ctx->sectorPrefixCorrected == NULL))
return aaruf_read_sector(context, sector_address, negative, data, length);
@@ -882,8 +882,8 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
case CdMode1:
memcpy(data + 16, bare_data, 2048);
if(ctx->sectorPrefix != NULL)
memcpy(data, ctx->sectorPrefix + corrected_sector_address * 16, 16);
if(ctx->sector_prefix != NULL)
memcpy(data, ctx->sector_prefix + corrected_sector_address * 16, 16);
else if(ctx->sectorPrefixDdt != NULL)
{
if((ctx->sectorPrefixDdt[corrected_sector_address] & CD_XFIX_MASK) == Correct)
@@ -934,8 +934,8 @@ int32_t aaruf_read_sector_long(void *context, const uint64_t sector_address, boo
case CdMode2Formless:
case CdMode2Form1:
case CdMode2Form2:
if(ctx->sectorPrefix != NULL)
memcpy(data, ctx->sectorPrefix + corrected_sector_address * 16, 16);
if(ctx->sector_prefix != NULL)
memcpy(data, ctx->sector_prefix + corrected_sector_address * 16, 16);
else if(ctx->sectorPrefixDdt != NULL)
{
if((ctx->sectorPrefixDdt[corrected_sector_address] & CD_XFIX_MASK) == Correct)

View File

@@ -574,13 +574,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
}
}
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
ctx->sectorPrefixBufferLength = 16 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
ctx->userDataDdtHeader.overflow);
ctx->sectorPrefixBuffer = malloc(ctx->sectorPrefixBufferLength);
ctx->sector_prefix_length = 16 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
ctx->userDataDdtHeader.overflow);
ctx->sector_prefix = malloc(ctx->sector_prefix_length);
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
FATAL("Could not allocate memory for CD sector prefix buffer");
@@ -644,19 +644,18 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
else
{
// Copy CD prefix from data buffer to prefix buffer
memcpy(ctx->sectorPrefixBuffer + ctx->sectorPrefixBufferOffset, data, 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] =
(uint16_t)(ctx->sectorPrefixBufferOffset / 16);
memcpy(ctx->sector_prefix + ctx->sector_prefix_offset, data, 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] = (uint16_t)(ctx->sector_prefix_offset / 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
ctx->sectorPrefixBufferOffset += 16;
ctx->sector_prefix_offset += 16;
// Grow prefix buffer if needed
if(ctx->sectorPrefixBufferOffset >= ctx->sectorPrefixBufferLength)
if(ctx->sector_prefix_offset >= ctx->sector_prefix_length)
{
ctx->sectorPrefixBufferLength *= 2;
ctx->sectorPrefixBuffer = realloc(ctx->sectorPrefixBuffer, ctx->sectorPrefixBufferLength);
ctx->sector_prefix_length *= 2;
ctx->sector_prefix = realloc(ctx->sector_prefix, ctx->sector_prefix_length);
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
FATAL("Could not allocate memory for CD sector prefix buffer");
@@ -732,13 +731,13 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
}
}
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
ctx->sectorPrefixBufferLength = 16 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
ctx->userDataDdtHeader.overflow);
ctx->sectorPrefixBuffer = malloc(ctx->sectorPrefixBufferLength);
ctx->sector_prefix_length = 16 * (ctx->userDataDdtHeader.negative + ctx->imageInfo.Sectors +
ctx->userDataDdtHeader.overflow);
ctx->sector_prefix = malloc(ctx->sector_prefix_length);
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
FATAL("Could not allocate memory for CD sector prefix buffer");
@@ -805,19 +804,18 @@ int32_t aaruf_write_sector_long(void *context, uint64_t sector_address, bool neg
else
{
// Copy CD prefix from data buffer to prefix buffer
memcpy(ctx->sectorPrefixBuffer + ctx->sectorPrefixBufferOffset, data, 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] =
(uint16_t)(ctx->sectorPrefixBufferOffset / 16);
memcpy(ctx->sector_prefix + ctx->sector_prefix_offset, data, 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] = (uint16_t)(ctx->sector_prefix_offset / 16);
ctx->sectorPrefixDdtMini[corrected_sector_address] |= SectorStatusErrored << 12;
ctx->sectorPrefixBufferOffset += 16;
ctx->sector_prefix_offset += 16;
// Grow prefix buffer if needed
if(ctx->sectorPrefixBufferOffset >= ctx->sectorPrefixBufferLength)
if(ctx->sector_prefix_offset >= ctx->sector_prefix_length)
{
ctx->sectorPrefixBufferLength *= 2;
ctx->sectorPrefixBuffer = realloc(ctx->sectorPrefixBuffer, ctx->sectorPrefixBufferLength);
ctx->sector_prefix_length *= 2;
ctx->sector_prefix = realloc(ctx->sector_prefix, ctx->sector_prefix_length);
if(ctx->sectorPrefixBuffer == NULL)
if(ctx->sector_prefix == NULL)
{
FATAL("Could not allocate memory for CD sector prefix buffer");

View File

@@ -65,7 +65,7 @@ int info(const char *path)
// TODO: Traverse media tags
if(ctx->sectorPrefix != NULL) printf("Sector prefix array has been read.\n");
if(ctx->sector_prefix != NULL) printf("Sector prefix array has been read.\n");
if(ctx->sectorPrefixCorrected != NULL) printf("Sector prefix corrected array has been read.\n");