Add error types and simple state
This commit is contained in:
13
src/memory.c
13
src/memory.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user