Initial commit, basic lexer structure
This commit is contained in:
21
src/error.h
Normal file
21
src/error.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef INCLUDE_SRC_ERROR_H_
|
||||
#define INCLUDE_SRC_ERROR_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct error {
|
||||
char *message;
|
||||
bool is_heap_allocated;
|
||||
} error_t;
|
||||
|
||||
error_t *errorf(const char *fmt, ...);
|
||||
static inline void error_free(error_t *err) {
|
||||
if (err == nullptr)
|
||||
return;
|
||||
if (!err->is_heap_allocated)
|
||||
return;
|
||||
free(err->message);
|
||||
free(err);
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SRC_ERROR_H_
|
Reference in New Issue
Block a user