summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/state.c10
-rw-r--r--head/atas/state.h7
2 files changed, 17 insertions, 0 deletions
diff --git a/core/state.c b/core/state.c
index 8c3dea1..eaca878 100644
--- a/core/state.c
+++ b/core/state.c
@@ -4,7 +4,9 @@
*/
#include <atas/state.h>
+#include <stdlib.h>
#include <errno.h>
+#include <assert.h>
int
atas_state_init(const char *in_file, struct atas_state *state)
@@ -32,3 +34,11 @@ atas_state_destroy(struct atas_state *state)
fclose(state->in_file);
state->in_file = NULL;
}
+
+void
+atas_fatal(struct atas_state *state)
+{
+ assert(state != NULL && "state cannot be NULL\n");
+ atas_state_destroy(state);
+ exit(1);
+}
diff --git a/head/atas/state.h b/head/atas/state.h
index 6e1fed9..186669f 100644
--- a/head/atas/state.h
+++ b/head/atas/state.h
@@ -35,4 +35,11 @@ int atas_state_init(const char *in_file, struct atas_state *state);
*/
void atas_state_destroy(struct atas_state *state);
+/*
+ * Used during fatal errors
+ *
+ * @state: Assembler state
+ */
+void atas_fatal(struct atas_state *state);
+
#endif /* !ATAS_STATE_H */