fix le memory leak
This commit is contained in:
10
src/Free/Arg.c
Normal file
10
src/Free/Arg.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeArg(GroundArg* in) {
|
||||
if (in->type == GroundArg_Value) {
|
||||
Ground.Free.Value(&in->as.value);
|
||||
} else {
|
||||
// FIXME - double free for arg
|
||||
// free(in->as.ref);
|
||||
}
|
||||
}
|
||||
10
src/Free/Instruction.c
Normal file
10
src/Free/Instruction.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeInstruction(GroundInstruction* in) {
|
||||
for (size_t i = 0; i < in->args.len; i++) {
|
||||
Ground.Free.Arg(&in->args.at[i]);
|
||||
}
|
||||
free(in->args.at);
|
||||
in->args.len = 0;
|
||||
in->args.capacity = 0;
|
||||
}
|
||||
10
src/Free/Program.c
Normal file
10
src/Free/Program.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeProgram(GroundProgram* in) {
|
||||
for (size_t i = 0; i < in->len; i++) {
|
||||
Ground.Free.Instruction(&in->at[i]);
|
||||
}
|
||||
free(in->at);
|
||||
in->len = 0;
|
||||
in->capacity = 0;
|
||||
}
|
||||
26
src/Free/State.c
Normal file
26
src/Free/State.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "../../include/ground.h"
|
||||
|
||||
void _GroundFreeState(GroundState* in) {
|
||||
{
|
||||
GroundVariable *s, *tmp;
|
||||
HASH_ITER(hh, in->variables, s, tmp) {
|
||||
Ground.Free.Value(&s->value);
|
||||
HASH_DEL(in->variables, s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
{
|
||||
GroundCatch *s, *tmp;
|
||||
HASH_ITER(hh, in->catches, s, tmp) {
|
||||
HASH_DEL(in->variables, s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
{
|
||||
GroundLabel *s, *tmp;
|
||||
HASH_ITER(hh, in->labels, s, tmp) {
|
||||
HASH_DEL(in->variables, s);
|
||||
free(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user