Skip to content

Commit

Permalink
Fix leaks, #33
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetras committed May 2, 2018
1 parent f00bc44 commit db6836e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: rnugroho <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/11/01 20:07:00 by rnugroho #+# #+# #
# Updated: 2018/05/02 02:16:31 by rnugroho ### ########.fr #
# Updated: 2018/05/02 15:26:33 by fpetras ### ########.fr #
# #
# **************************************************************************** #

Expand Down Expand Up @@ -322,4 +322,4 @@ tests_vm_op_overflow: corewar

tests: tests_asm tests_vm

.PHONY: all clean fclean re debug norm norm2 tests tests_asm test_asm_leak tests_asm_leak tests_asm_valid tests_asm_error tests_asm_v libft
.PHONY: all clean fclean re debug norm norm2 tests tests_asm test_asm_leak tests_asm_leak tests_asm_valid tests_asm_error tests_asm_v libft
18 changes: 17 additions & 1 deletion src/ft_vm/ft_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@
/* By: rnugroho <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/19 21:38:33 by rnugroho #+# #+# */
/* Updated: 2018/05/02 14:35:30 by rnugroho ### ########.fr */
/* Updated: 2018/05/02 15:51:07 by fpetras ### ########.fr */
/* */
/* ************************************************************************** */

#include "ft_vm.h"
#include "ft_vm_draw.h"

void
vm_free(t_vm *vm)
{
int i;

i = 0;
while (i < vm->champ_size)
{
free(vm->champ[i].op);
fta_clear(vm->champ[i].processes);
free(vm->champ[i].processes);
i++;
}
}

void
vm_load_champs(t_vm *vm, unsigned char memory[MEM_SIZE])
{
Expand Down Expand Up @@ -111,5 +126,6 @@ int
ft_printfln("Contestant %d, \"%s\", has won !",
vm.winner + 1, vm.champ[vm.winner].header.prog_name) : 0;
(vm.v_lvl[V_LVL_1]) ? draw_end(&g_draw_win) : 0;
vm_free(&vm);
return (0);
}

0 comments on commit db6836e

Please sign in to comment.