diff --git a/src/error.c b/src/error.c index 008c588..9ede6cb 100644 --- a/src/error.c +++ b/src/error.c @@ -10,6 +10,9 @@ error_t *const err_errorf_length = &(error_t){ .message = "Formatting of another error failed to determine the error length"}; +error_t *err_allocation_failed = + &(error_t){.message = "Memory allocation failed"}; + error_t *errorf(const char *fmt, ...) { error_t *err = calloc(1, sizeof(error_t)); if (err == nullptr) diff --git a/src/error.h b/src/error.h index 5a6f143..96374e0 100644 --- a/src/error.h +++ b/src/error.h @@ -18,4 +18,7 @@ static inline void error_free(error_t *err) { free(err); } +/* Some global errors */ +extern error_t *err_allocation_failed; + #endif // INCLUDE_SRC_ERROR_H_ diff --git a/src/lexer.c b/src/lexer.c index be808cc..08a96bd 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -20,9 +20,6 @@ error_t *err_eof = error_t *err_unknown_read = &(error_t){.message = "Unknown read error"}; -error_t *err_allocation_failed = - &(error_t){.message = "Memory allocation failed"}; - typedef bool (*char_predicate_t)(char); const char *lexer_token_id_to_cstr(lexer_token_id_t id) {