Add error types and simple state

This commit is contained in:
2022-10-28 16:08:40 -04:00
parent fd91e66b8a
commit ed173bd17a
14 changed files with 302 additions and 89 deletions

View File

@@ -40,6 +40,14 @@ struct nl_object *nl_string_create(const char *string)
return obj;
}
struct nl_object *nl_error_create(const char *error)
{
struct nl_object* obj = nl_object_alloc();
obj->type = NL_TYPE_ERROR;
obj->error = error;
return obj;
}
static struct nl_object* nl_object_alloc() {
return malloc(sizeof(struct nl_object));
}
@@ -63,6 +71,11 @@ void nl_object_delete(struct nl_object *obj) {
case NL_TYPE_STRING:
free((void *) obj->string);
obj->string = NULL;
break;
case NL_TYPE_ERROR:
free((void *) obj->error);
obj->error = NULL;
break;
case NL_TYPE_INT:
case NL_TYPE_COUNT:
break;