fix le memory leak
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
|
||||
for (size_t i = 0; i < program->len; i++) {
|
||||
for (size_t j = 0; j < program->len; j++) {
|
||||
GroundArg* arg = &program->at[i].args.at[j];
|
||||
if (arg->type == GroundArg_Label) {
|
||||
GroundInstruction* instruction = &program->at[i];
|
||||
if (instruction->type == GroundInstruction_CREATELABEL) {
|
||||
if (instruction->args.len > 0) {
|
||||
GroundArg* arg = &instruction->args.at[0];
|
||||
GroundLabel* label = NULL;
|
||||
HASH_FIND_STR(state->labels, arg->as.ref, label);
|
||||
|
||||
@@ -20,6 +21,8 @@ static inline void doLabels(GroundProgram* program, GroundState* state) {
|
||||
Ground.Flags.error = true;
|
||||
return;
|
||||
}
|
||||
strncpy(label->name, arg->as.ref, 2047);
|
||||
label->name[2047] = '\0';
|
||||
label->lineNum = i;
|
||||
HASH_ADD_STR(state->labels, name, label);
|
||||
}
|
||||
@@ -139,8 +142,7 @@ void _GroundInternalRun(GroundProgram* program, GroundState* state) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// TODO: implement
|
||||
// Ground.Free.Instruction(&instruction);
|
||||
Ground.Free.Instruction(&instruction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user