Skip to content

Commit

Permalink
ci(memoryl_leaks): Fix CI valgrind check and resolve function memory
Browse files Browse the repository at this point in the history
leaks

Signed-off-by: SIGMazer <[email protected]>
  • Loading branch information
SIGMazer committed Feb 8, 2025
1 parent 0505aa1 commit 261a935
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -3435,6 +3435,7 @@ void free_ast(ASTNode *node)
case NODE_FUNCTION_DEF:
SAFE_FREE(node->data.function_def.name);
// Free parameters
free_parameters(node->data.function_def.parameters);
if (node->data.function_def.body)
{
free_ast(node->data.function_def.body);
Expand Down Expand Up @@ -3786,6 +3787,7 @@ void enter_function_scope(Function *func, ArgumentList *args)
Variable *var = variable_new(curr_param->name);
var->var_type = curr_param->type;
add_variable_to_scope(curr_param->name, var);
SAFE_FREE(var);

switch (curr_param->type)
{
Expand All @@ -3810,5 +3812,6 @@ void enter_function_scope(Function *func, ArgumentList *args)
}
curr_param = curr_param->next;
}
reverse_parameter_list(&func->parameters);
}

6 changes: 5 additions & 1 deletion run_valgrind_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ for f in test_cases/*.brainrot; do
else
valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
fi
if [[ $? -ne 0 ]]; then
echo "Valgrind failed on $f"
exit 1
fi
echo
done
done

0 comments on commit 261a935

Please sign in to comment.