Add function to free Compact Disc ECC context and update cleanup logic

This commit is contained in:
2025-12-28 17:04:14 +00:00
parent a93dcfc3d4
commit 2ce7e053e0
3 changed files with 20 additions and 1 deletions

View File

@@ -110,6 +110,8 @@ AARU_EXPORT int32_t AARU_CALL aaruf_cst_untransform(const uint8_t *sequential, u
AARU_EXPORT void *AARU_CALL aaruf_ecc_cd_init();
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_free(void *context);
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct(void *context, const uint8_t *sector);
AARU_EXPORT bool AARU_CALL aaruf_ecc_cd_is_suffix_correct_mode2(void *context, const uint8_t *sector);

View File

@@ -91,6 +91,23 @@ AARU_EXPORT void *AARU_CALL aaruf_ecc_cd_init()
return context;
}
/**
* @brief Frees a Compact Disc ECC context and its internal tables.
*
* @param ctx Pointer to the CdEccContext to free.
*/
AARU_EXPORT void AARU_CALL aaruf_ecc_cd_free(void *ctx)
{
if(!ctx) return;
CdEccContext *context = (CdEccContext *)ctx;
free(context->ecc_f_table);
free(context->ecc_b_table);
free(context->edc_table);
free(context);
}
/**
* @brief Checks if the suffix (EDC/ECC) of a CD sector is correct (Mode 1).
*

View File

@@ -4568,7 +4568,7 @@ AARU_EXPORT int AARU_CALL aaruf_close(void *context)
free(ctx->readableSectorTags);
ctx->readableSectorTags = NULL;
free(ctx->ecc_cd_context);
aaruf_ecc_cd_free(ctx->ecc_cd_context);
ctx->ecc_cd_context = NULL;
free(ctx->checksums.spamsum);