From 208cb375e1a1478b04ee593c4e614eb3eb7994a2 Mon Sep 17 00:00:00 2001 From: Pradana Aumars Date: Tue, 1 Jun 2021 00:58:30 +0200 Subject: [PATCH] Add exception_init and exception_free --- src/exception_t.c | 15 +++++++++++++++ src/exception_t.h | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/src/exception_t.c b/src/exception_t.c index c141bbc..da8cbaf 100644 --- a/src/exception_t.c +++ b/src/exception_t.c @@ -1 +1,16 @@ +#include + #include "exception_t.h" + +exception_t* +exception_init() { + exception_t *e = (exception_t*) malloc(sizeof(exception_t)); + e->type = NO_ERROR; + e->msg = NULL; + return e; +} + +void +exception_free(exception_t *e) { + free(e); +} diff --git a/src/exception_t.h b/src/exception_t.h index 4abab9e..ba6af43 100644 --- a/src/exception_t.h +++ b/src/exception_t.h @@ -15,6 +15,12 @@ typedef struct exception_t { char *msg; } exception_t; +exception_t* +exception_init(); + +void +exception_free(exception_t *e); + char* exception_str(exception_t *e);