Initial commit
This commit is contained in:
19
src/Free/Function.c
Normal file
19
src/Free/Function.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeFunction(GroundFunction* in) {
|
||||
if (!in->isNativeFunction) {
|
||||
Ground.Free.Program(in->program.ground);
|
||||
free(in->program.ground);
|
||||
|
||||
for (size_t i = 0; i < in->args.count; i++) {
|
||||
free(in->args.at[i].as.id);
|
||||
}
|
||||
}
|
||||
|
||||
Ground.Free.State(in->closure);
|
||||
free(in->closure);
|
||||
|
||||
free(in->args.at);
|
||||
in->args.count = 0;
|
||||
in->args.capacity = 0;
|
||||
}
|
||||
9
src/Free/List.c
Normal file
9
src/Free/List.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void _GroundFreeList(GroundList* in) {
|
||||
free(in->at);
|
||||
in->capacity = 0;
|
||||
in->count = 0;
|
||||
}
|
||||
15
src/Free/Object.c
Normal file
15
src/Free/Object.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void _GroundFreeObject(GroundObject* in) {
|
||||
GroundObjectField *s, *tmp;
|
||||
|
||||
HASH_ITER(hh, in->fields, s, tmp) {
|
||||
|
||||
HASH_DEL(in->fields, s);
|
||||
|
||||
Ground.Free.Value(s->value);
|
||||
free(s->value);
|
||||
}
|
||||
}
|
||||
8
src/Free/String.c
Normal file
8
src/Free/String.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void _GroundFreeString(GroundString* in) {
|
||||
free(in->cstr);
|
||||
in->len = 0;
|
||||
}
|
||||
15
src/Free/Struct.c
Normal file
15
src/Free/Struct.c
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void _GroundFreeStruct(GroundStruct* in) {
|
||||
GroundObjectField *s, *tmp;
|
||||
|
||||
HASH_ITER(hh, in->fields, s, tmp) {
|
||||
|
||||
HASH_DEL(in->fields, s);
|
||||
|
||||
Ground.Free.Value(s->value);
|
||||
free(s->value);
|
||||
}
|
||||
}
|
||||
30
src/Free/Value.c
Normal file
30
src/Free/Value.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeValue(GroundValue* in) {
|
||||
switch (in->type.type) {
|
||||
case GroundType_String: {
|
||||
Ground.Free.String(&in->as.String);
|
||||
break;
|
||||
}
|
||||
case GroundType_List: {
|
||||
Ground.Free.List(&in->as.List);
|
||||
break;
|
||||
}
|
||||
case GroundType_Function: {
|
||||
Ground.Free.Function(&in->as.Function);
|
||||
break;
|
||||
}
|
||||
case GroundType_Struct: {
|
||||
Ground.Free.Struct(&in->as.Struct);
|
||||
break;
|
||||
}
|
||||
case GroundType_Object: {
|
||||
Ground.Free.Object(&in->as.Object);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user