diff --git a/include/bal_errors.h b/include/bal_errors.h index db164fc4..38f695f2 100644 --- a/include/bal_errors.h +++ b/include/bal_errors.h @@ -20,6 +20,7 @@ extern "C" BAL_SUCCESS = 0, BAL_ERROR_INVALID_ARGUMENT = -1, BAL_ERROR_ALLOCATION_FAILED = -2, + BAL_ERROR_STRUCT_CORRUPTED = -3, // Memory and Translation Errors @@ -62,7 +63,7 @@ extern "C" BAL_ERROR_BRANCH_OFFSET_OVERFLOW = -202, /// The provided buffer capacity is too large and would cause an integer overflow. - BAL_ERROR_INVALID_CAPACITY = -203, + BAL_ERROR_CAPACITY_TOO_BIG = -203, } bal_error_t; /// Converts the enum into a readable string for error handling. diff --git a/src/bal_errors.c b/src/bal_errors.c index d78211f4..b26e267b 100644 --- a/src/bal_errors.c +++ b/src/bal_errors.c @@ -11,8 +11,10 @@ bal_error_to_string(const bal_error_t error) return "function argument is NULL or invalid"; case BAL_ERROR_ALLOCATION_FAILED: return "failed to allocate memory"; + case BAL_ERROR_STRUCT_CORRUPTED: + return "struct integrity check failed"; - // --- Memory & Translation --- + // --- Memory & Translation --- case BAL_ERROR_MEMORY_ALIGNMENT: return "buffer is not aligned to the required memory alignment"; case BAL_ERROR_MEMORY_FAULT: @@ -39,7 +41,7 @@ bal_error_to_string(const bal_error_t error) return "decoded register type mismatch"; case BAL_ERROR_BRANCH_OFFSET_OVERFLOW: return "relative branch offset exceeds displacement limit"; - case BAL_ERROR_INVALID_CAPACITY: + case BAL_ERROR_CAPACITY_TOO_BIG: return "buffer capacity is too large and would cause integer overflow"; default: